<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">客户名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="customerName" class="layui-input" type="text"
                                               placeholder="请输入客户名称"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="customerQuery" layui-form-keyDownSearch="true" lay-submit>查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                </div>
                            </div>
                            <div class="query-rt"></div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                            <button id="customersInfoBtnAdd" class="layui-btn icon-btn color-reseda">添加
                            </button>
                            <button id="fromLocalWarehouseBtnImport" class="layui-btn icon-btn color-reseda">
                                <input id="uploaderInput" type="file" name="file" class="import" accept=".xls,.xlsx"/>导入
                            </button>
                        </div>
                        <div class="lay-btn-rt">
                            <button id="fromLocalWarehouseBtnTemplate" class="layui-btn icon-btn ">模板下载
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="customersInfoTable" lay-filter="customersInfoTable"></table>
        </div>
    </div>
</div>


<style>
    .width105 {
        width: 105px;
    }

    .borderNone {
        border: none;
    }

    /*物料目录样式*/
    div[lay-id="customerTable2"] .layui-table-cell,
    div[lay-id="customerTable2"] .layui-form,
    div[lay-id="customerTable2"] .layui-table-box,
    div[lay-id="customerTable2"] .layui-table-body {
        overflow: visible;
    }

    div[lay-id="specValue"] .layui-table-cell,
    div[lay-id="specValue"] .layui-form,
    div[lay-id="specValue"] .layui-table-box,
    div[lay-id="specValue"] .layui-table-body {
        overflow: visible;
    }

    .storageWorkIsSelect .layui-table-cell {
        height: auto;
        max-height: 100px;
    }

    .msg-none .layui-none {
        display: none !important;
    }

    /*导入*/
    .import {
        opacity: 0;
        position: absolute;
        width: 69px;
        height: 38px;
        margin-left: -10px;
    }

    /*尽调样式*/
    div[lay-id="addDueTable"] .layui-table-box,
    div[lay-id="addDueTable"] .layui-table-body,
    div[lay-id="addDueTable"] .layui-table-cell {
        overflow: visible;
        padding: 0 1px;
    }

    div[lay-id="addDueTable"] .layui-table-cell {
        height: auto;
        padding: 0 10px;
        word-break: break-word;
        white-space: pre-line;
    }

    .subjectDetailBox > div {
        margin-right: 10px !important;
    }

    [lay-filter="addDueForm"] .open-details-box::-webkit-scrollbar {
        display: none;
        width: 0;
    }

    #addCustomerProductForm .layui-form-select .layui-input {
        text-align: center;
        padding-right: 20px;
    }

    #addCustomerProductForm xm-select .xm-label .scroll .label-content {
        justify-content: center;
    }

    #addCustomerProductForm xm-select > .xm-tips {
        width: 100%;
        justify-content: center;
    }
</style>

<!-- 表格操作列 -->
<script type="text/html" id="customersInfoTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="due">尽调</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="custContract">合同</a>
    <a class="layui-btn  layui-btn-xs" lay-event="contact">联系人</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="product">物料目录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="followRecord">跟进记录</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="customersInfoForm">
    <form lay-filter="customersInfoForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <input name="approverName" id="approverNameHidden" type="hidden"/>
        <input name="salesmanName" id="salesmanNameHidden" type="hidden"/>
        <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label">客户类型</label>
                <div class="layui-input-block">
                    <select name="customerType" id="customerType">
                        <option value="">请选择客户类型</option>
                        <option value="potential">潜在客户</option>
                        <option value="Intended">意向客户</option>
                        <option value="formal" selected>正式客户</option>
                    </select>
                </div>
            </div>
        </div>
        <!--        <div class="layui-col-xs6">-->
        <!--            <div class="layui-form-item">-->
        <!--                <label class="layui-form-label">所属代理商</label>-->
        <!--                <div class="layui-input-block">-->
        <!--                    <select name="selAgtId" lay-search></select>-->
        <!--                </div>-->
        <!--            </div>-->
        <!--        </div>-->
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>客户名称</label>
                <div class="layui-input-block">
                    <input name="customerName" placeholder="请输入客户名称" type="text" class="layui-input"
                           lay-verify="required"
                           required/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>营业执照号</label>
                <div class="layui-input-block">
                    <input name="licenseNo" placeholder="请输入营业执照号" type="text" class="layui-input"
                           lay-verify="required"
                           required/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">省</label>
                <div class="layui-input-block">
                    <input type="hidden" name="provinceName"/>
                    <select name="province" id="province" lay-filter="province"></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">市</label>
                <div class="layui-input-block">
                    <input type="hidden" name="cityName"/>
                    <select name="city" id="city" lay-filter="city"></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">区</label>
                <div class="layui-input-block">
                    <input type="hidden" name="areaName"/>
                    <select name="area" id="area" lay-filter="area"></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">详情地址</label>
                <div class="layui-input-block">
                    <input name="address" placeholder="请输入详情地址" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>联系人姓名</label>
                <div class="layui-input-block">
                    <input name="contactName" placeholder="请输入联系人姓名" type="text" class="layui-input"
                           lay-verify="required"
                           required/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>职务</label>
                <div class="layui-input-block">
                    <select name="postId" id="postId" lay-filter="postId" lay-verify="required" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">所属部门</label>
                <div class="layui-input-block">
                    <input name="department" placeholder="请输入所属部门" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">名片</label>
                <div class="layui-input-block">
                    <div id="btnUpload15" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传文件
                    </div>
                    <div id="btnUpload15_path" style="margin-left: 150px;line-height: 40px;"></div>
                    <input id="btnUpload15_file" name="visitingCard" type="hidden"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>电话</label>
                <div class="layui-input-block">
                    <input name="telephone" placeholder="请输入电话" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">微信号</label>
                <div class="layui-input-block">
                    <input name="wechatNumber" placeholder="请输入微信号" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input name="email" placeholder="请输入邮箱" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>线索来源</label>
                <div class="layui-input-block">
                    <select name="clueSourceId" id="clueSourceId" lay-filter="clueSourceId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">推荐人</label>
                <div class="layui-input-block">
                    <input name="referees" placeholder="请输入推荐人" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">年用刀量</label>
                <div class="layui-input-block">
                    <input name="dosage" placeholder="请输入年用刀量" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">业务员</label>
                <div class="layui-input-block">
                    <select name="salesmanId" lay-filter="salesman" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-form-item">
                <label class="layui-form-label">审批人</label>
                <div class="layui-input-block">
                    <select name="approver" lay-filter="approver" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="customersInfoFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!--详情弹框-->
<script type="text/html" id="detailTable">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 正式客户详细列表 -->
                <table class="layui-table" id="customersDetailTable" lay-filter="customersDetailTable"></table>
                <!-- 选项 -->
                <div class="layui-tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">客户基本信息</li>
                        <li>客户联系人信息</li>
                        <li>财务信息</li>
                        <li>跟进记录</li>
                        <li>客户线索信息</li>
                    </ul>
                    <div class="layui-tab-content">
                        <!--客户基本信息-->
                        <div class="layui-tab-item layui-show">
                            <form lay-filter="customersDetailForm" class="layui-form model-form">
                                <input name="id" type="hidden"/>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">企业名称</label>
                                        <div class="layui-input-inline">
                                            <input name="name" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">营业执照号</label>
                                        <div class="layui-input-inline">
                                            <input name="licenseNo" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">所在地址</label>
                                        <div class="layui-input-inline">
                                            <input name="addr" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">营业执照照片</label>
                                        <div class="uploadImgStyle" id="licensePhoto">
                                            <input type="hidden" name="licensePhoto" lay-verify=""
                                                   data-name="营业执照照片"
                                                   disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">企业性质</label>
                                        <div class="layui-input-inline">
                                            <input name="" placeholder="" type="text" class="layui-input borderNone"
                                                   disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">客户所属分类</label>
                                        <div class="layui-input-inline">
                                            <input name="agentCategoryName" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">收款银行</label>
                                        <div class="layui-input-inline">
                                            <input name="bankName" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">收款银行户名</label>
                                        <div class="layui-input-inline">
                                            <input name="bankAccount" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">收款银行账号</label>
                                        <div class="layui-input-inline">
                                            <input name="bankCard" placeholder="" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6" style="height: 170px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">开户许可证</label>
                                        <div class="uploadImgStyle" id="license">
                                            <input type="hidden" name="openingPermit" lay-verify=""
                                                   data-name="开户许可证" disabled/>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item text-right">
                                    <button class="layui-btn" type="button" ew-event="closeDialog">返回</button>
                                </div>
                            </form>
                        </div>

                        <!--客户联系人信息-->
                        <div class="layui-tab-item">
                            <!-- 头部操作栏 -->
                            <div class="layui-form lay-header">
                                <div class="toolbar">
                                    <div class="layui-form-item lay-query-content">
                                        <div class="lay-query-box">
                                            <div class="query-lt">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label w-auto">客户名称：</label>
                                                    <div class="layui-input-inline">
                                                        <input name="customerName" class="layui-input" type="text"
                                                               placeholder="请输入客户名称"/>
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <button class="layui-btn icon-btn color-green"
                                                            lay-filter="formSubSearchLog" lay-submit>查询
                                                    </button>
                                                </div>
                                            </div>
                                            <div class="query-rt"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="lay-btn-rows">
                                    <div class="lay-btn-box">
                                        <div class="lay-btn-lt">
                                            <button id="contactInfoBtnAdd" class="layui-btn icon-btn"><i
                                                    class="layui-icon">&#xe654;</i>添加
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 客户联系人表格 -->
                            <table class="layui-table" id="contactInfoTable" lay-filter="contactInfoTable"></table>
                        </div>

                        <!--财务信息-->
                        <div class="layui-tab-item">
                            <!--      头部操作      -->
                            <form class="layui-form lay-header">
                                <div class="toolbar">
                                    <div class="layui-form-item lay-query-content">
                                        <div class="lay-query-box">
                                            <div class="query-lt">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">账单编号:</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" class="layui-input" name="billNo"
                                                               placeholder="账单名称/编号">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">起始日期:</label>
                                                    <div class="layui-input-inline">
                                                        <input name="createTime" id="pTimeBill"
                                                               class="layui-input date-icon" type="text"
                                                               placeholder="选择时间" style="width: 200px"/>
                                                    </div>
                                                    <input name="startTime" id="sTimeBill" type="hidden"/>
                                                    <input name="endTime" id="eTimeBill" type="hidden"/>
                                                </div>
                                            </div>
                                            <div class="query-rt">
                                                <div class="layui-inline">
                                                    <a lay-filter="formSearch"
                                                       class="layui-btn icon-btn color-green" lay-submit
                                                       type="button">查询
                                                    </a>
                                                    <button class="layui-btn icon-btn color-white"
                                                            lay-filter="resets" type="reset"
                                                            id="formResets">重置
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                            <!--   账单列表        -->
                            <table class="layui-table" id="billTable" lay-filter="billTable"></table>
                        </div>
                        <!--跟进记录-->
                        <div class="layui-tab-item">
                            <!-- 头部操作栏 -->
                            <div class="layui-form lay-header">
                                <div class="lay-btn-rows">
                                    <div class="lay-btn-box">
                                        <div class="lay-btn-lt">
                                            <button id="customerFollowRecordBtnAdd" class="layui-btn icon-btn"><i
                                                    class="layui-icon">&#xe654;</i>添加
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 表格 -->
                            <table class="layui-table" id="customerFollowRecordTable"
                                   lay-filter="customerFollowRecordTable"></table>
                        </div>
                        <!--客户线索信息-->
                        <div class="layui-tab-item">
                            <form lay-filter="customerLeadsForm" class="layui-form model-form">
                                <input name="id" type="hidden"/>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">客户录入渠道</label>
                                        <div class="layui-input-inline">
                                            <input name="agentName" type="text" class="layui-input borderNone"
                                                   disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">客户录入人</label>
                                        <div class="layui-input-inline">
                                            <input name="agtCreatorName" type="text" class="layui-input borderNone"
                                                   disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">客户录入电话</label>
                                        <div class="layui-input-inline">
                                            <input name="agtCreatorPhone" id="agtCreatorPhone" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">签单人</label>
                                        <div class="layui-input-inline">
                                            <input name="signer" type="text" class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">签单人电话</label>
                                        <div class="layui-input-inline">
                                            <input name="signerPhone" type="text" class="layui-input borderNone"
                                                   disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">所属服务专员</label>
                                        <div class="layui-input-inline">
                                            <select name="salesmanId" id="salesmanId" lay-filter="salesmanId"
                                                    lay-verify="required" required lay-search></select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label width105">服务专员电话</label>
                                        <div class="layui-input-inline">
                                            <input name="salesmanPhone" id="salesmanPhone" type="text"
                                                   class="layui-input borderNone" disabled/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item text-right">
                                    <button class="layui-btn" type="button" ew-event="closeDialog">返回</button>
                                    <button class="layui-btn" id="customersLeadsUpdate"
                                            lay-filter="customersLeadsUpdate" lay-submit>保存
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>

<!--客户物料目录div-->
<div id="cpml">
    <!--物料目录-按钮弹窗-->
    <script type="text/html" id="productCatalogHtml">
        <!-- 正文开始 -->
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body">
                    <!-- 头部操作栏 -->
                    <div class="layui-form lay-header">
                        <button id="customerProductCatalogBtnAdd" class="layui-btn icon-btn"><i
                                class="layui-icon">&#xe654;</i>添加
                        </button>
                    </div>

                    <!-- 表格 -->
                    <table class="layui-table" id="customerTable" lay-filter="customerTable"></table>

                    <table class="layui-table" id="customerProductCatalogTable"
                           lay-filter="customerProductCatalogTable"></table>
                </div>
            </div>
        </div>

    </script>

    <!-- 物料目录-表格操作列 -->
    <script type="text/html" id="customerProductCatalogTableBar">
        <!--<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">详情</a>
        <!--<a class="layui-btn  layui-btn-xs" lay-event="">成本核算</a>-->
    </script>
    <!--物料目录添加-表单弹框-->
    <script type="text/html" id="addCustomerProduct">
        <div class="layui-card">
            <div class="layui-card-body">
                <form lay-filter="addCustomerProductForm" id="addCustomerProductForm" class="layui-form model-form"
                      style="padding: 0px 10px 0px 0px">
                    <div class="layui-row table-bor storageWorkIsSelect" style="margin-top: 0px">
                        <span>客户与订单信息：</span>
                        <table class="layui-table" id="customerTable2" lay-filter="customerTable2"></table>
                    </div>

                    <div class="layui-row table-bor storageWorkIsSelect" style="margin-top: 20px">
                        <span>客户物料信息：</span>
                        <!--<table class="layui-table" id="customerProductTable" lay-filter="customerProductTable"></table>-->
                        <table class="layui-table" id="customeProTable">
                            <thead>
                            <tr>
                                <th style="text-align: center">客户物料名称</th>
                                <th style="text-align: center">客户物料编号</th>
                                <th style="text-align: center">客户规格码</th>
                                <th style="text-align: center">上传附件</th>
                                <th style="text-align: center">是否需要包装</th>
                                <th style="text-align: center">包装说明</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td><!--客户物料名称-->
                                    <input type="text" name="extProductName" id="extProductName"
                                           placeholder="请输入客户物料名称"
                                           autocomplete="off" class="layui-input customClass"
                                           style="text-align: center">
                                </td>
                                <td><!--客户物料编号-->
                                    <input type="text" name="extProductCode" id="extProductCode"
                                           placeholder="请输入客户物料编号"
                                           autocomplete="off" class="layui-input customClass"
                                           style="text-align: center">
                                </td>
                                <td><!--客户规格码-->
                                    <input type="text" name="extSpecCode" id="extSpecCode"
                                           placeholder="请输入客户规格码"
                                           autocomplete="off" class="layui-input customClass"
                                           style="text-align: center">
                                </td>
                                <td><!--上传附件-->
                                    <div id="btnUploadExt" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传文件
                                    </div>
                                    <div id="btnUploadExt_path" class="uploadImgStyle"
                                         style="margin-left: 50px;line-height: 40px;"></div>
                                    <input id="btnUploadExt_file" name="enclosure" type="hidden"/>
                                </td>
                                <td><!--是否需要包装-->
                                    <select name="packing" id="packing" lay-filter="packing"
                                            style="text-align: center; line-height: 30px; height: 30px;">
                                        <option value="">请选择是否需要包装</option>
                                        <option value="0">需要</option>
                                        <option value="1">不需要</option>
                                    </select>
                                </td>
                                <td><!--包装说明-->
                                    <input type="text" name="packingRequire" id="packingRequire"
                                           placeholder="请输入包装说明" autocomplete="off"
                                           class="layui-input customClass" style="text-align: center">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="layui-row table-bor storageWorkIsSelect" style="margin-top: 20px">
                        <span>物料内部信息：</span>
                        <table class="layui-table" id="productTable">
                            <thead>
                            <tr>
                                <th style="text-align: center;">内部物料类型</th>
                                <th style="text-align: center;">内部物料分类</th>
                                <th style="text-align: center;">所属内部物料系列</th>
                                <th style="text-align: center;">内部物料系列编号</th>
                                <th style="text-align: center;">基础计量单位</th>
                                <th style="text-align: center;">客户物料备注</th>
                                <th style="text-align: center;">物料参考成本<br>(选材规格历史参考)</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td><!--内部物料类型-->
                                    <select name="productTypeId" id="productTypeId" lay-filter="productTypeId"
                                            lay-verify="required" class="customClass"
                                            lay-search></select>
                                </td>
                                <td><!--内部物料分类-->
                                    <div class="layui-form-item" id="categoryDiv" style="margin-bottom: 0px;">
                                        <input name="productCategoryId" value="" type="hidden" class="layui-input">
                                        <div class="layui-input-inline mr0" id="productCategoryId">
                                        </div>
                                    </div>
                                </td>
                                <td><!--所属内部物料系列-->
                                    <select name="productRange" id="productRange" lay-filter="productRange"
                                            class="customClass"
                                            lay-search></select>
                                </td>
                                <td><!--内部物料系列编号-->
                                    <input type="text" name="rangeCode" id="rangeCode" placeholder="" autocomplete="off"
                                           class="layui-input" disabled style="text-align: center">
                                </td>
                                <td><!--基础计量单位-->
                                    <input name="unitId" id="unitId" type="hidden"/>
                                    <input type="text" name="unitName" id="unitName" placeholder=""
                                           autocomplete="off" class="layui-input" disabled style="text-align: center">
                                </td>
                                <td><!--客户物料备注-->
                                    <input type="text" name="remark" id="remark" placeholder="请输入" autocomplete="off"
                                           class="layui-input customClass" style="text-align: center">
                                </td>
                                <td><!--物料参考成本-->
                                    ￥
                                </td>

                            </tr>
                            </tbody>
                        </table>
                        <table class="layui-table" id="skuTable">
                            <tbody>
                            <tr>
                                <th style="text-align: center;">规格码</th>
                                <th style="text-align: center;">成品料号（SKUID）</th>
                                <th style="text-align: center;">物料规格名称</th>
                                <th style="text-align: center;">包装单位</th>
                                <th style="text-align: center;">包装方案</th>
                                <th style="text-align: center;">重量</th>
                            </tr>
                            </tbody>
                            <tbody>
                            <tr>
                                <td><!--规格码-->
                                    <div class="layui-row table-bor msg-none" id="ggm">
                                        <table class="layui-table" id="specValue" lay-filter="specValue"
                                               style="margin: 0;"></table>
                                    </div>
                                    <div class="layui-row table-bor storageWorkIsSelect" id="ggmInp">
                                        <input type="text" name="specValueNames" id="specValueNames"
                                               class="layui-input customClass">
                                    </div>
                                </td>

                                <td><!--成品料号-->
                                    <input type="text" name="skuCode" id="skuCode" placeholder="" autocomplete="off"
                                           class="layui-input customClass">
                                    <!--{{# if(d.skuValueCount == 1){ }}
                                    <input type="text" name="skuCode" id="skuCode" placeholder="" autocomplete="off"
                                           class="layui-input customClass">
                                    {{# } else{ }}
                                    <select name="skuCodeSel" id="skuCodeSel" lay-filter="skuCodeSel" class="customClass"
                                            lay-search></select>
                                    {{# } }}-->
                                </td>
                                <td><!--物料规格名称-->
                                    <input type="text" name="skuName" id="skuName" placeholder="" autocomplete="off"
                                           class="layui-input customClass">
                                </td>

                                <td><!--包装单位-->
                                    <div class="layui-input-inline">
                                        <select name="packUnitId" id="packUnitId" lay-filter="packUnitId"
                                                class="customClass"
                                                lay-search></select>
                                    </div>
                                </td>
                                <td><!--包装方案-->
                                    <div class="layui-input-inline">
                                        <select name="productPack" id="productPack" lay-filter="productPack"
                                                class="customClass"
                                                lay-search></select>
                                    </div>
                                </td>
                                <td><!--重量-->
                                    <input type="text" name="weight" id="weight" placeholder="单位g" autocomplete="off"
                                           class="layui-input customClass">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="layui-form-item text-right" style="padding-top: 10px;">
                        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                        <button class="layui-btn" type="button" lay-filter="addCustomerProductSubmit"
                                id="addCustomerProductSubmit" lay-submit>提交
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </script>
    <!--选择联系人下拉框-->
    <script type="text/html" id="contactNameTemplate">
        <form lay-filter="addCustomerProductForm" class="layui-form model-form" style="padding: 0;">
            <select name="contactId" id="contactId" lay-filter="contactId" lay-verify="required"
                    class="customClass"></select>
        </form>
    </script>
</div>

<!--客户联系人div-->
<div id="lxr">
    <!--客户联系人-按钮弹窗-->
    <script type="text/html" id="contactHtml">
        <!-- 正文开始 -->
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body">
                    <!-- 头部操作栏 -->
                    <div class="layui-form lay-header">
                        <div class="toolbar">
                            <div class="layui-form-item lay-query-content">
                                <div class="lay-query-box">
                                    <div class="query-lt">
                                        <div class="layui-inline">
                                            <label class="layui-form-label w-auto">客户名称：</label>
                                            <div class="layui-input-inline">
                                                <input name="customerName" class="layui-input" type="text"
                                                       placeholder="请输入客户名称"/>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                                    lay-submit>查询
                                            </button>
                                        </div>
                                    </div>
                                    <div class="query-rt"></div>
                                </div>
                            </div>
                        </div>
                        <div class="lay-btn-rows">
                            <div class="lay-btn-box">
                                <div class="lay-btn-lt">
                                    <button id="contactInfoBtnAdd2" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 客户联系人表格 -->
                    <table class="layui-table" id="contactInfoTable2" lay-filter="contactInfoTable"></table>
                </div>
            </div>
        </div>
    </script>

    <!-- 客户联系人-表格操作列 -->
    <script type="text/html" id="contactInfoTableBar">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    </script>

    <!-- 客户联系人-表单弹窗 -->
    <script type="text/html" id="contactInfoForm">
        <form lay-filter="contactInfoForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">所属客户</label>
                    <div class="layui-input-block">
                        <select name="selCustomerId" lay-filter="selCustomerId" lay-verify="required" required
                                lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>联系人姓名</label>
                    <div class="layui-input-block">
                        <input name="name" placeholder="请输入联系人姓名" type="text" class="layui-input"
                               lay-verify="required"
                               required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <select name="sex">
                            <option value="">请选择性别</option>
                            <option value="man">男</option>
                            <option value="woman">女</option>
                            <option value="other">未知</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>职务</label>
                    <div class="layui-input-block">
                        <select name="postId" id="contactPostId" lay-filter="postId" lay-verify="required"
                                lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">所属部门</label>
                    <div class="layui-input-block">
                        <input name="department" placeholder="请输入所属部门" type="text" class="layui-input"
                               lay-verify="required"
                               required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>电话</label>
                    <div class="layui-input-block">
                        <input name="telephone" placeholder="请输入电话" type="text" class="layui-input"
                               lay-verify="required"
                               required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">微信号</label>
                    <div class="layui-input-block">
                        <input name="wechatNumber" placeholder="请输入微信号" type="text" class="layui-input"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-block">
                        <input name="email" placeholder="请输入邮箱" type="text" class="layui-input"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">通讯地址</label>
                    <div class="layui-input-block">
                        <input name="mailAddress" placeholder="请输入通讯地址" type="text" class="layui-input"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input name="sort" placeholder="" type="text" class="layui-input"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red"></span>联系人照片</label>
                    <div id="btnUpload14" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传文件
                    </div>
                    <div id="btnUpload14_path" style="margin-left: 260px;line-height: 40px;"></div>
                    <input id="btnUpload14_file" name="picture" type="hidden" lay-verify="contactShot"
                           lay-verType="alert"/>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label">名片</label>
                    <div class="layui-input-block">
                        <div id="btnUpload16" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传文件
                        </div>
                        <div id="btnUpload16_path" style="margin-left: 150px;line-height: 40px;"></div>
                        <input id="btnUpload16_file" name="visitingCard" type="hidden"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入备注" maxlength="200"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="contactInfoFormSubmit" lay-submit>保存</button>
            </div>
        </form>
    </script>
</div>

<!--财务信息div-->
<div id="cwxx">
    <style>
        .billMian {
            margin-bottom: 25px;
            border-bottom: 1px solid #e0dfdf;
        }

        .bill {
            box-sizing: border-box;
            padding: 20px 10px;
        }

        .bill .billBox {
            min-height: 100px;
            padding: 20px 12px;
            box-sizing: border-box;
            background-color: #F9FAFE;
            color: #5f5f5f;
        }

        .billBox h3 {
            padding-bottom: 12px;
            font-size: 12px;
        }

        .billBox p {
            font-style: normal;
            font-size: 30px;
            font-weight: 500;
            color: #009C5E;
        }

        .bill-title {
            width: 100%;
            height: 40px;
            padding: 0 20px;
            font-size: 15px;
            font-weight: 500;
            background: #F9FAFE;
            position: relative;
            display: flex;
            align-items: center;
            /*margin: 10px 0;*/
            box-sizing: border-box;
        }

        .bill-title:before {
            content: " ";
            display: inline-block;
            width: 4px;
            height: 16px;
            background: #009C5E;
            margin-right: 10px;
        }

        .viewBill label {
            width: 120px;
        }

        .viewBill input[type='text']:not(.layui-unselect), .viewBillBorderNone {
            border: none;
        }

        .viewBill input[type='text'].viewBillBorderShow {
            border: 1px solid #e6e6e6;
        }

        .viewBill textarea {
            resize: none;
            width: 300px;
            height: 80px;
            box-sizing: border-box;
            padding: 10px;
        }

        .layui-table-cell {
            height: auto;
            max-height: 80px;
        }

        .colorRed {
            color: #ff0000;
        }

        .capital .capitalBoxList {
            background-color: #F9FAFE;
            padding: 20px 0;
            border-top: solid #fff 2px;
            min-height: 580px;
        }

        .capitalBoxList label {
            padding: 9px 5px;
            width: 100px;
        }

        .capitalBoxList input {
            border: none;
            background-color: #F9FAFE;
        }

        .mergeInfo {
            float: left;
        }

        .mergeInfo .layui-input-block {
            margin-left: 0;
        }

        .mergeInfo label {
            width: 45px;
        }

        .mergeInfo .layui-input-inline {
            width: 300px;
            margin-bottom: 10px;
        }

        .settlementInfoView label, .invoiceInfoView label {
            width: 100px;
        }
    </style>
    <!--财务信息-表格操作列-->
    <script type="text/html" id="billTableBar">
        <a class="layui-btn layui-btn-xs" lay-event="details">详情</a>

        {{# if(d.billStatus=="confirm"){  }}
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="viewBillBtn">确认</a>
        {{# }else if(d.billStatus == "insettle" || d.billStatus == "settled"){ }}
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="settlementInfoBtn">结算信息</a>
        <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="invoiceInfoBtn">发票信息</a>
        {{# }else{ }}
        {{# } }}
    </script>

    <!--财务信息-详情弹窗-->
    <script type="text/html" id="billDetails">
        <div class="layui-card">
            <div class="layui-card-body">
                <!--    账单详情统计        -->
                <div class="layui-field-box">
                    <div class="bill-title">柜子业务月度统计</div>
                    <div class="layui-row layui-col-space10 bill">
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单总应结金额（元人民币）</h3>
                                <p id="xq_billTotalMoney"></p>
                            </div>
                        </div>
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单订单数</h3>
                                <p id="xq_billOrdAmount"></p>
                            </div>
                        </div>
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单已结算金额</h3>
                                <p id="xq_billSettledMoney"></p>
                            </div>
                        </div>
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单未结算金额（元人民币）</h3>
                                <p id="xq_billNosettledMoney"></p>
                            </div>
                        </div>
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单已开票金额</h3>
                                <p id="xq_billInvoicedMoney"></p>
                            </div>
                        </div>
                        <div class="layui-col-md2">
                            <div class="billBox">
                                <h3>账单未开票金额</h3>
                                <p id="xq_billNoinvoicedMoney"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 收款 结算 发票信息  -->
                <div class="layui-field-box capital">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md4">
                            <div class="bill-title">收款账户信息</div>
                            <div class="capitalBoxList">
                                <form class="layui-form model-form" lay-filter="moneyCollectAccountInfoForm"
                                      style="padding: 0">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开户行：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="incomeBank" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账户：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="incomeAccount" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账号：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payNumber" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单金额：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="billTotalMoney" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单起止时间：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="startTime" class="layui-input" disabled>
                                            <input type="text" name="endTime" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单出账时间：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="createTime" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单备注：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="examineRemark" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单确认人：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="confirmName" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单确认结果：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="confirmResultDesc" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单确认时间：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="confirmTime" class="layui-input" disabled>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="bill-title">结算信息</div>
                            <div class="capitalBoxList">
                                <form class="layui-form model-form" lay-filter="settlementInformationForm"
                                      style="padding: 0">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开户行：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payBank" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账户：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payAccount" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账号：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payNumber" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账单金额：</label>
                                        <div class="layui-input-block">
                                            <input type="hidden" name="payMoney" class="layui-input" disabled>
                                            <span style="line-height: 38px;padding-left: 10px" id="payMoneySpan"></span>
                                            <a class="layui-btn-xs" id="payMoneyBtn"
                                               style="display: none">查看结算信息</a>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款凭证：</label>
                                        <div class="layui-input-block">
                                            <div id="payFile_path" class="uploadImgStyle"></div>
                                            <input name="payFile" type="hidden" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款凭证号：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payFileNo" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款时间：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="createTime" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款人：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payName" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款方式：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="payModeDesc" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">付款备注：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="remark" class="layui-input" disabled>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="bill-title">发票信息</div>
                            <div class="capitalBoxList">
                                <form class="layui-form model-form" lay-filter="invoiceInfoForm" style="padding: 0">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">发票总金额：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="invoiceMoney" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">发票税额：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="taxMoney" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">发票税率：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="taxRate" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">发票张数：</label>
                                        <div class="layui-input-block">
                                            <input type="hidden" name="count" class="layui-input-inline" disabled>
                                            <span style="line-height: 38px;padding-left: 10px" id="countSpan"></span>
                                            <a class="layui-btn-xs" id="countBtn" style="display: none">查看开票记录</a>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">发票凭证：</label>
                                        <div class="layui-input-block">
                                            <div id="xq_invoiceFile_path" class="uploadImgStyle"></div>
                                            <input name="invoiceFile" type="hidden" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开票时间：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="createTime" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开票人：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="drawer" class="layui-input" disabled>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开票备注：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="remark" class="layui-input" disabled>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!--   账单列表        -->
                <table class="layui-table" id="billDetailsTable" lay-filter="billDetailsTable"></table>
            </div>
        </div>
    </script>

    <!--财务信息-审核账单-->
    <script type="text/html" id="viewBill">
        <div class="layui-card viewBill">
            <div class="layui-card-body">
                <form lay-filter="viewBillForm" class="layui-form model-form">
                    <input name="id" type="hidden"/>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>账单编号</label>
                        <div class="layui-input-inline">
                            <input name="billNo" class="layui-input" type="text" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>账单起止时间</label>
                        <div class="layui-input-inline">
                            <input name="startTime" class="layui-input" type="text" readonly="readonly"/>
                            <input name="endTime" class="layui-input" type="text" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>我方付款账号</label>
                        <div class="mergeInfo">
                            <div class="layui-input-block">
                                <label class="layui-form-label ">开户行</label>
                                <div class="layui-input-inline">
                                    <input name="payBank" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                            <div class="layui-input-block">
                                <label class="layui-form-label">账户</label>
                                <div class="layui-input-inline">
                                    <input name="payAccount" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                            <div class="layui-input-block">
                                <label class="layui-form-label">账号</label>
                                <div class="layui-input-inline">
                                    <input name="payNumber" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>对方收款账号</label>
                        <div class="mergeInfo">
                            <div class="layui-input-block">
                                <label class="layui-form-label ">开户行</label>
                                <div class="layui-input-inline">
                                    <input name="incomeBank" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                            <div class="layui-input-block">
                                <label class="layui-form-label ">账户</label>
                                <div class="layui-input-inline">
                                    <input name="incomeAccount" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                            <div class="layui-input-block">
                                <label class="layui-form-label ">账号</label>
                                <div class="layui-input-inline">
                                    <input name="incomeNumber" class="layui-input viewBillBorderShow" type="text"
                                           readonly="readonly"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>账单金额</label>
                        <div class="layui-input-inline">
                            <input name="billTotalMoney" class="layui-input" type="text" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>优惠金额</label>
                        <div class="layui-input-inline">
                            <input name="discountMoney" class="layui-input" type="text" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label "><span class="colorRed">*</span>最终金额</label>
                        <div class="layui-input-inline">
                            <input name="finalMoney" class="layui-input" type="text" readonly="readonly"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ">确认结果</label>
                        <div class="layui-input-inline">

                            <select name="confirmResult" lay-verify="required" id="confirmResult"
                                    lay-filter="confirmResult">
                                <option value="">请选择</option>
                                <option value="pass">相符</option>
                                <option value="refuse">不相符</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ">内部备注</label>
                        <div class="layui-input-block">
                            <textarea name="confirmRemark"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item" id="confirmRefuseRemarkBox" style="display: none">
                        <label class="layui-form-label ">驳回备注留言</label>
                        <div class="layui-input-block">
                            <textarea name="confirmRefuseRemark" id="confirmRefuseRemark"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-inline">
                            <button class="layui-btn" type="button" lay-submit="" lay-filter="viewBillSubmit">提交
                            </button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </script>

    <!--财务信息-結算信息-->
    <script type="text/html" id="settlementInfoView">
        <div class="layui-card settlementInfoView">
            <div class="layui-card-body">
                <form lay-filter="settlementInfoViewForm" class="layui-form model-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">起始日期：</label>
                            <div class="layui-input-inline">
                                <input name="settlementInfo_createTime" id="settlementInfo_pTime"
                                       class="layui-input date-icon" type="text" placeholder="选择时间"
                                       style="width: 200px"/>
                            </div>
                            <input name="startTime" id="settlementInfo_sTime" type="hidden"/>
                            <input name="endTime" id="settlementInfo_eTime" type="hidden"/>
                        </div>
                        <div class="layui-inline">
                            <a class="layui-btn" lay-submit lay-filter="settlementInfoViewFormSearch">搜索</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <a class="layui-btn" id="addPaymentInfo">添加支付凭证信息</a>
                    </div>
                    <div class="layui-form-item">
                        <!--   账单列表        -->
                        <table class="layui-table" id="settlementInfoViewTable"
                               lay-filter="settlementInfoViewTable"></table>
                    </div>
                </form>
            </div>
        </div>
    </script>

    <!--财务信息-结算信息 操作列-->
    <script type="text/html" id="settlementInfoBar">
        <a class="layui-btn layui-btn-xs" lay-event="settlementInfoDetailsBtn">详情</a>
    </script>

    <!--财务信息-結算信息 支付凭证信息和详情-->
    <script type="text/html" id="settlementInfoDetails">
        <div class="layui-card viewBill">
            <div class="layui-card-body">
                <form lay-filter="settlementInfoDetailsForm" class="layui-form model-form settlementInfoDetails">
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单编号</label>
                            <div class="layui-input-inline">
                                <input name="billNo" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单金额</label>
                            <div class="layui-input-inline">
                                <input name="billTotalMoney" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单开始时间</label>
                            <div class="layui-input-inline">
                                <input name="startTime" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单结束时间</label>
                            <div class="layui-input-inline">
                                <input name="endTime" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">结算账号-开户行</label>
                            <div class="layui-input-inline">
                                <input name="payBank" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">结算账号-账户</label>
                            <div class="layui-input-inline">
                                <input name="payAccount" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">结算账号-账号</label>
                            <div class="layui-input-inline">
                                <input name="payNumber" class="layui-input viewBillBorderNone" type="text"
                                       readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">付款方式</label>
                            <div class="layui-input-inline">
                                <select name="payMode" lay-verify="required" id="payMode">
                                    <option value="">请选择付款方式</option>
                                    <option value="online">网银转账</option>
                                    <option value="offline">线下汇款</option>
                                    <option value="cash">现金</option>
                                    <option value="other">其他</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">付款账号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="payNumber" class="layui-input viewBillBorderNone"
                                       readonly="readonly">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">支付币种</label>
                            <div class="layui-input-inline">
                                <select name="currency" lay-verify="required">
                                    <option value="">请选择支付币种</option>
                                    <option value="RMB">人民币(元)</option>
                                    <option value="dollar">美元</option>
                                    <option value="other ">其他</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">付款金额</label>
                            <div class="layui-input-inline">
                                <input name="payMoney" class="layui-input" type="number" lay-verify="required"
                                       value=""/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">付款凭证号</label>
                            <div class="layui-input-inline">
                                <input name="payFileNo" class="layui-input viewBillBorderShow" type="text"
                                       lay-verify="required"
                                       value=""/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">支付凭证附件</label>
                            <div class="layui-input-block">
                                <div id="devicePic_path" class="uploadImgStyle"></div>
                                <div id="devicePicBtn" class="layui-btn" style="float: left;"><i
                                        class="layui-icon">&#xe681;</i>上传图片
                                </div>
                                <input name="payFile" type="hidden" class="layui-input" lay-verify="" id="payFile"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">账单审核人</label>
                            <div class="layui-input-inline">
                                <input type="text" name="billAuditor" class="layui-input viewBillBorderNone">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">是否本人转账</label>
                            <div class="layui-input-inline">
                                <select name="transferor" lay-filter="transferor" readonly="readonly">
                                    <option value="">请选择是否本人转账</option>
                                    <option value="self">是本人(当前账号)</option>
                                    <option value="other">不是本人(不是当前账号)</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item" id="payNameBox" style="display: none">
                            <label class="layui-form-label">支付操作人</label>
                            <div class="layui-input-inline">
                                <input name="payName" type="text" class="layui-input viewBillBorderShow" id="payName"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label">客户备注留言</label>
                            <div class="layui-input-block">
                                <textarea name="remark" style="width: 90%"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label">结算说明</label>
                            <div class="layui-input-block">
                                <textarea name="settleRemark" style="width: 90%"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" id="settlementInfoDetailsSubmitBox">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-inline">
                            <a class="layui-btn" type="button" lay-submit
                               lay-filter="settlementInfoDetailsSubmit">提交</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </script>

    <!--财务信息-发票信息-->
    <script type="text/html" id="invoiceInfoView">
        <div class="layui-card invoiceInfoView">
            <div class="layui-card-body">
                <form lay-filter="invoiceInfoViewForm" class="layui-form model-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">起始日期：</label>
                            <div class="layui-input-inline">
                                <input name="invoiceInfo_createTime" id="invoiceInfo_pTime"
                                       class="layui-input date-icon"
                                       type="text" placeholder="选择时间" style="width: 200px"/>
                            </div>
                            <input name="startTime" id="invoiceInfo_sTime" type="hidden"/>
                            <input name="endTime" id="invoiceInfo_eTime" type="hidden"/>
                        </div>
                        <div class="layui-inline">
                            <a class="layui-btn" lay-filter="invoiceInfoViewFormSearch" lay-submit>搜索</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <!--   账单列表        -->
                        <table class="layui-table" id="invoiceInfoViewTable" lay-filter="invoiceInfoViewTable"></table>
                    </div>
                </form>
            </div>
        </div>
    </script>

    <!--财务信息-发票信息 操作列-->
    <script type="text/html" id="invoiceInfoViewBar">
        <a class="layui-btn layui-btn-xs" lay-event="invoiceInfoViewDetailsBtn">详情</a>
    </script>

    <!--财务信息-发票信息 详情-->
    <script type="text/html" id="invoiceInfoDetails">
        <div class="layui-card viewBill">
            <div class="layui-card-body">
                <form lay-filter="invoiceInfoDetailsForm" class="layui-form model-form">
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单编号</label>
                            <div class="layui-input-inline">
                                <input name="billNo" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>开票企业名称</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseName" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">客户结算-开户行</label>
                            <div class="layui-input-inline">
                                <input name="incomeBank" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">客户结算-账户</label>
                            <div class="layui-input-inline">
                                <input name="incomeAccount" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">客户结算-账号</label>
                            <div class="layui-input-inline">
                                <input name="incomeNumber" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单开始时间</label>
                            <div class="layui-input-inline">
                                <input name="startTime" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单结束时间</label>
                            <div class="layui-input-inline">
                                <input name="endTime" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">付款-开户行</label>
                            <div class="layui-input-inline">
                                <input name="payBank" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">付款-账户</label>
                            <div class="layui-input-inline">
                                <input name="payAccount" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label ">付款-账号</label>
                            <div class="layui-input-inline">
                                <input name="payNumber" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单金额</label>
                            <div class="layui-input-inline">
                                <input name="billTotalMoney" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>结算状态</label>
                            <div class="layui-input-inline">
                                <input name="billStatus" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label "><span class="colorRed">*</span>账单确认人</label>
                            <div class="layui-input-inline">
                                <input name="confirmName" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">账单确认时间</label>
                            <div class="layui-input-inline">
                                <input name="confirTime" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">已开票数量</label>
                            <div class="layui-input-inline">
                                <input name="num" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">待开票金额</label>
                            <div class="layui-input-inline">
                                <input name="pendingMoney" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">发票科目</label>
                            <div class="layui-input-inline">
                                <input name="invoiceSubject" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">发票税号</label>
                            <div class="layui-input-inline">
                                <input name="invoiceTaxno" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">开票金额</label>
                            <div class="layui-input-inline">
                                <input name="invoiceMoney" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">发票附件</label>
                            <div class="layui-input-block">
                                <div id="invoiceFile_path" class="uploadImgStyle"></div>
                                <input name="invoiceFile" type="hidden" class="layui-input" lay-verify=""
                                       id="invoiceFile"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">开票操作人</label>
                            <div class="layui-input-inline">
                                <input name="drawer" class="layui-input" type="text" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label">客户备注留言</label>
                            <div class="layui-input-block">
                                <textarea name="remark" disabled style="width: 90%"></textarea>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </script>
</div>

<!--跟进记录div-->
<div id="gjjl">
    <!-- 跟进记录-表格操作列 -->
    <script type="text/html" id="customerFollowRecordTableBar">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
        {{# if(d.status =="pendingReview"){ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="process">审核</a>
        {{# } }}
    </script>

    <!-- 跟进记录-按钮弹窗 -->
    <script type="text/html" id="followRecordHtml">
        <!-- 正文开始 -->
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body">
                    <!-- 头部操作栏 -->
                    <div class="layui-form lay-header">
                        <div class="toolbar">
                            <div class="layui-form-item lay-query-content">
                                <div class="lay-query-box">
                                    <div class="query-lt">
                                        <div class="layui-inline">
                                            <label class="layui-form-label w-auto">跟进客户：</label>
                                            <div class="layui-input-inline">
                                                <select name="followCustomer"></select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                                    lay-submit>查询
                                            </button>
                                        </div>
                                    </div>
                                    <div class="query-rt"></div>
                                </div>
                            </div>
                        </div>
                        <div class="lay-btn-rows">
                            <div class="lay-btn-box">
                                <div class="lay-btn-lt">
                                    <button id="customerFollowRecordBtnAdd2" class="layui-btn icon-btn"><i
                                            class="layui-icon">&#xe654;</i>添加
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 表格 -->
                    <table class="layui-table" id="customerFollowRecordTable2"
                           lay-filter="customerFollowRecordTable"></table>
                </div>
            </div>
        </div>
    </script>

    <!-- 跟进记录-表单弹窗 -->
    <script type="text/html" id="customerFollowRecordForm">
        <form lay-filter="customerFollowRecordForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">客户类型</label>
                    <div class="layui-input-inline">
                        <select name="customerType" id="followCustomerType" lay-filter="customerType" disabled="disabled">
                            <option value="">请选择客户类型</option>
                            <option value="potential">潜在客户</option>
                            <option value="Intended">意向客户</option>
                            <option value="formal">正式客户</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进类型</label>
                    <div class="layui-input-inline">
                        <select name="followType" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进客户</label>
                    <div class="layui-input-inline">
                        <select name="followCustomer" lay-filter="followCustomer" lay-verify="required" required
                                lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进对象</label>
                    <div class="layui-input-inline">
                        <select name="followTarget" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进方式</label>
                    <div class="layui-input-inline">
                        <select name="followWay" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进结果类型</label>
                    <div class="layui-input-inline">
                        <select name="followResult" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">产生费用</label>
                    <div class="layui-input-inline">
                        <input name="cost" placeholder="请输入产生费用" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">审批人</label>
                    <div class="layui-input-inline">
                        <select name="approver" lay-filter="approver" lay-verify="required" required
                                lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进结果描述</label>
                    <div class="layui-input-block">
                        <textarea name="followDescribe" placeholder="请输入跟进结果描述" maxlength="200"
                                  style="width: 90%"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入备注" maxlength="200" style="width: 90%"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <input name="approverName" id="followApproverName" type="hidden"/>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="customerFollowRecordFormSubmit" lay-submit>保存</button>
            </div>
        </form>
    </script>

    <!-- 跟进记录-详情表单弹窗 -->
    <script type="text/html" id="customerFollowRecordDetailForm">
        <form lay-filter="customerFollowRecordDetailForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">客户类型</label>
                    <div class="layui-input-inline">
                        <select name="customerType" class="selectDisabled">
                            <option value="">请选择客户类型</option>
                            <option value="potential">潜在客户</option>
                            <option value="Intended">意向客户</option>
                            <option value="formal">正式客户</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进类型</label>
                    <div class="layui-input-inline">
                        <select name="followType" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进客户</label>
                    <div class="layui-input-inline">
                        <select name="followCustomer" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进对象</label>
                    <div class="layui-input-inline">
                        <select name="followTarget" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进对象职务</label>
                    <div class="layui-input-inline">
                        <input name="postName" type="text" class="layui-input selectDisabled"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进对象电话</label>
                    <div class="layui-input-inline">
                        <input name="telephone" type="text" class="layui-input selectDisabled"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进方式</label>
                    <div class="layui-input-inline">
                        <select name="followWay" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进结果类型</label>
                    <div class="layui-input-inline">
                        <select name="followResult" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">产生费用</label>
                    <div class="layui-input-inline">
                        <input name="cost" type="text" class="layui-input selectDisabled"/>
                    </div>
                    <!--<div class="layui-form-mid layui-word-aux">单位：元</div>-->
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">提交时间</label>
                    <div class="layui-input-inline">
                        <input name="createTime" type="text" class="layui-input selectDisabled"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">审批时间</label>
                    <div class="layui-input-inline">
                        <input name="checkTime" type="text" class="layui-input selectDisabled"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">审批人</label>
                    <div class="layui-input-inline">
                        <select name="approver" class="selectDisabled" lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">跟进结果描述</label>
                    <div class="layui-input-block">
                        <textarea name="followDescribe" maxlength="200" class="layui-textarea"
                                  style="width: 90%"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 110px;">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" id="followRemark" maxlength="200" class="layui-textarea"
                                  style="width: 90%"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn" id="customerFollowRecordDetailFormSubmit"
                        lay-filter="customerFollowRecordDetailFormSubmit" lay-submit>保存
                </button>
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            </div>
        </form>
    </script>
</div>

<!--客户合同div-->
<div id="khxt">
    <!--合同-按钮弹窗-->
    <script type="text/html" id="customerContractHtml">
        <style>
            .layui-form-label {
                width: 100px;
            }

            .layui-input-block {
                margin-left: 130px;
            }

            .companyFormPhotos {
                margin-left: 50px;
                line-height: 38px;
                float: left;
                margin-right: 30px;
            }

            .companyFormPhotos img {
                height: 38px;
                width: auto;
                max-width: 200px;
            }

            .attachments {
                cursor: pointer;
                display: block;
                float: left;
                overflow: hidden;
                text-align: center;
                padding: 0 10px;
                width: 100px;
            }

            .option-item {
                overflow: hidden;
                color: #1E9FFF;
                text-align: center;
                height: 20px;
                line-height: 20px;
            }

            .preview {
                cursor: pointer;
                float: left;
            }

            .download {
                cursor: pointer;
                float: right;
            }

            .file-a {
                font-size: 12px;
                word-break: break-all;
                text-overflow: ellipsis;
                overflow: hidden;
                display: -webkit-box;
                -webkit-line-clamp: 1;
                -webkit-box-orient: vertical;
                margin-top: 5px;
            }

            .info_row {
                height: 30px;
                line-height: 30px;
            }

            #categorySearch xm-select {
                min-height: 32px;
                line-height: 32px;
                border-radius: 4px;
            }
        </style>
        <!-- 正文开始 -->
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body">
                    <!-- 头部操作栏 -->
                    <div class="layui-form lay-header">
                        <div class="toolbar">
                            <div class="layui-form-item lay-query-content">
                                <div class="lay-query-box">
                                    <div class="query-lt">
                                        <div class="layui-inline" id="categorySearch">
                                            <input name="contractCategoryId" type="hidden"/>
                                            <div class="layui-input-inline mr0" id="selContractCategory">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline mr0">
                                                <input name="companyName" class="layui-input" type="text"
                                                       placeholder="请输入签约主体名称"/>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline mr0">
                                                <input name="code" class="layui-input" type="text"
                                                       placeholder="请输入合同编号"/>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline mr0">
                                                <input name="contactName" class="layui-input" type="text"
                                                       placeholder="请输入客户签约人"/>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline mr0">
                                                <input name="createTime" id="pTime" class="layui-input date-icon"
                                                       type="text"
                                                       placeholder="请选择时间段" style="width: 200px"/>
                                            </div>
                                            <input name="startCreateTime" id="sTime" type="hidden"/>
                                            <input name="endCreateTime" id="eTime" type="hidden"/>
                                        </div>
                                    </div>
                                    <div class="query-rt">
                                        <div class="layui-inline">
                                            <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                                    lay-submit>查询
                                            </button>
                                            <button class="layui-btn icon-btn color-white" lay-filter="resets"
                                                    lay-submit>重置
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="lay-btn-rows">
                            <div class="lay-btn-box">
                                <div class="lay-btn-lt">
                                    <button id="contractBtnAdd" class="layui-btn icon-btn color-reseda">添加</button>
                                </div>
                                <div class="lay-btn-rt"></div>
                            </div>
                        </div>
                    </div>
                    <!-- 表格 -->
                    <table class="layui-table" id="contractTable" lay-filter="contractTable"></table>
                </div>
            </div>
        </div>
    </script>

    <!-- 合同-表格操作列 -->
    <script type="text/html" id="contractTableBar">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="view">详情</a>
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="changeRecord">变更记录</a>
        {{# if(d.status == 'hasSign'){ }}
        <a class="layui-btn layui-btn-xs" lay-event="relatedProduct">物料</a>
        {{# } }}
    </script>

    <script type="text/html" id="viewAttachmentBar">
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="viewAttachment">查看附件</a>
    </script>

    <!-- 合同-表单弹窗 -->
    <script type="text/html" id="contractForm">
        <form lay-filter="contractForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>合同主体类型</label>
                    <div class="layui-input-block">
                        <select name="type" disabled></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item" id="PID">
                    <label class="layui-form-label"><span style="color: red">*</span>合同分类</label>
                    <input name="contractCategoryId" type="hidden" lay-verify="contractCategoryId"/>
                    <div class="layui-input-block" id="selectContractCategory">
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>签约主体名称</label>
                    <div class="layui-input-block">
                        <select name="subjectId" disabled></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>合同名称</label>
                    <div class="layui-input-block">
                        <input name="name" placeholder="请输入合同名称" type="text" class="layui-input" maxlength="200"
                               lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>合同编号</label>
                    <div class="layui-input-block">
                        <input name="code" placeholder="请输入合同编号" type="text" class="layui-input" maxlength="200"
                               lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>客户签约人</label>
                    <div class="layui-input-block">
                        <select name="contactsId" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>我方签约人</label>
                    <div class="layui-input-block">
                        <select name="contractor" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>信息审批人</label>
                    <div class="layui-input-block">
                        <select name="approver" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>签约金额</label>
                    <div class="layui-input-block">
                        <input name="amount" placeholder="请输入签约金额" type="text" class="layui-input"
                               lay-verify="required|decimal" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>上传附件</label>
                    <div class="layui-input-block">
                        <div id="addDevicePicBtn" class="layui-btn" style="float: left;margin-left: 3px"><i
                                class="layui-icon">&#xe681;</i>上传PDF文件
                        </div>
                        <div id="addHeaderImg" class="companyFormPhotos"></div>
                        <input name="attachment" id="attachment" type="hidden" class="layui-input"
                               lay-verify="attachment"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入备注" maxlength="200"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="contractFormSubmit" lay-submit>保存</button>
            </div>
        </form>
    </script>

    <!-- 合同-详情 -->
    <script type="text/html" id="contractView">
        <div style="padding: 20px;">
            <table class="layui-table">
                <thead>
                <tr>
                    <th style="width: 35%;">合同信息</th>
                    <th>合同PDF预览内容</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td id="contractInfo">

                    </td>
                    <td>
                        <div id="attachmentName" style="margin-bottom: 10px; font-size: 16px;">合同附件：</div>
                        <div id="example1" style="height: 500px;"></div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </script>

    <!-- 合同-审核 -->
    <script type="text/html" id="contractAuditForm">
        <form lay-filter="contractAuditForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-form-item">
                <label class="layui-form-label">审核意见</label>
                <div class="layui-input-block">
                    <textarea name="auditOpinion" placeholder="请输入审核意见" maxlength="200"
                              class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn" data-status="success" lay-filter="contractAuditFormSubmit" lay-submit>
                    审核通过
                </button>
                <button class="layui-btn layui-btn-danger" data-status="fail" lay-filter="contractAuditFormSubmit"
                        lay-submit>审核不通过
                </button>
            </div>
        </form>
        <div style="padding: 20px;">
            <table class="layui-table">
                <thead>
                <tr>
                    <th style="width: 35%;">合同信息</th>
                    <th>合同PDF预览内容</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td id="contractInfo">

                    </td>
                    <td>
                        <div id="attachmentName" style="margin-bottom: 10px; font-size: 16px;">合同附件：</div>
                        <div id="example1" style="height: 500px;"></div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </script>

    <!-- 合同信息 -->
    <script type="text/html" id="contractInfoHtml">
        <div class="info_row">客户名称：{{d.companyName}}</div>
        <div class="info_row">合同名称：{{d.name}}</div>
        <div class="info_row">合同编号：{{d.code}}</div>
        <div class="info_row">客户签约人：{{d.contactName}}</div>
        <div class="info_row" id="contractorName">我方签约人：{{d.contractorName}}</div>
        <div class="info_row">签约时间：{{d.signingTime ? d.signingTime : ""}}</div>
        <div class="info_row">交货时间：{{d.deliveryTime ? d.deliveryTime : ""}}</div>
        <div class="info_row">备注信息：{{d.remark}}</div>
        <div class="info_row">合同金额：{{d.amount}}</div>
        <div style="overflow: hidden; padding: 5px 0;">
            <div style="float: left;">合同附件：</div>
            {{# var attachment = "";
            if(d.attachment){
            attachment = d.attachment.substring(d.attachment.lastIndexOf("/")+1);
            }
            var time = timeStamp2String(d.createTime);
            }}
            <div class="attachments">
                <div onclick="previewFile('{{attachment}}', '{{d.attachment}}');">
                    <img src="../../../admin/assets/images/attachmentsIcon/pdf.png">
                    <span class="file-a">{{attachment}}</span>
                    <span class="file-a">{{time}}</span>
                </div>
            </div>
        </div>
        <div class="info_row">合同存放地点：{{d.address ? d.address : ""}}</div>
        <div class="info_row" id="keeperName">合同保管员：{{d.keeperName ? d.keeperName : ""}}</div>
        <!--<div class="info_row">合同状态：{{d.statusDesc}}</div>-->
        <div class="info_row" id="approverName">信息审批人：{{d.approverName ? d.approverName : ""}}</div>
        <div class="info_row">审核结果：{{d.statusDesc ? d.statusDesc : ""}}</div>
        <div class="info_row">审核意见备注：{{d.auditOpinion ? d.auditOpinion : ""}}</div>
    </script>

    <!-- 合同-查看附件 -->
    <script type="text/html" id="viewAttachmentHtml">
        <div id="example1" style="height: 100%;"></div>
    </script>

    <!-- 合同-变更记录 -->
    <script type="text/html" id="contractChangeRecord">
        <div class="layui-card">
            <div class="layui-card-body" id="changeRecord">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">合同编号：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="code" class="layui-input" type="text"
                                                   placeholder="请输入编号"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green"
                                                lay-filter="contractChangeRecordFormSubSearchLog" lay-submit>查询
                                        </button>
                                        <button class="layui-btn icon-btn color-white"
                                                lay-filter="contractChangeRecordResets" lay-submit>重置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows" id="opBtn">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                                <button id="contractChangeRecordBtnAdd" class="layui-btn icon-btn color-reseda">
                                    添加合同变更记录
                                </button>
                            </div>
                            <div class="lay-btn-rt">

                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="contractChangeRecordTable"
                       lay-filter="contractChangeRecordTable"></table>
            </div>
        </div>
    </script>

    <!-- 合同-表单弹窗 -->
    <script type="text/html" id="contractChangeRecordForm">
        <form lay-filter="contractChangeRecordForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-col-xs6">
                <div class="layui-form-item" id="PID">
                    <label class="layui-form-label"><span style="color: red">*</span>合同分类</label>
                    <input name="contractCategoryId" type="hidden" lay-verify="contractCategoryId"/>
                    <div class="layui-input-block" id="selectContractCategory">
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>签约主体名称</label>
                    <div class="layui-input-block">
                        <input name="companyName" type="text" class="layui-input" style="border: 0;" readonly/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>合同名称</label>
                    <div class="layui-input-block">
                        <input name="name" placeholder="请输入合同名称" type="text" class="layui-input" maxlength="200"
                               lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>合同编号</label>
                    <div class="layui-input-block">
                        <input name="code" placeholder="请输入合同编号" type="text" class="layui-input" readonly
                               maxlength="200" lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>客户签约人</label>
                    <div class="layui-input-block">
                        <select name="contactsId" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>我方签约人</label>
                    <div class="layui-input-block">
                        <select name="contractor" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>签约时间</label>
                    <div class="layui-input-block">
                        <input name="signingTime" id="signingTime" placeholder="请选择签约时间" type="text"
                               class="layui-input" readonly lay-verify="required" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>信息审批人</label>
                    <div class="layui-input-block">
                        <select name="approver" lay-verify="required" required lay-search></select>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>签约金额</label>
                    <div class="layui-input-block">
                        <input name="amount" placeholder="请输入签约金额" type="text" class="layui-input"
                               lay-verify="required|decimal" required/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>是否最终版</label>
                    <div class="layui-input-block">
                        <input name="isFinal" type="checkbox" lay-skin="switch" lay-filter="isFinal" lay-text="是|否"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>上传附件</label>
                    <div class="layui-input-block">
                        <div id="addDevicePicBtn" class="layui-btn" style="float: left;margin-left: 3px"><i
                                class="layui-icon">&#xe681;</i>上传PDF文件
                        </div>
                        <div id="addHeaderImg" class="companyFormPhotos"></div>
                        <input name="attachment" id="attachment" type="hidden" class="layui-input"
                               lay-verify="attachment"/>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                    <textarea name="remark" placeholder="请输入备注信息" maxlength="200"
                              class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <div id="content" style="display: none;">
                <div class="layui-col-xs6">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">*</span>交货时间</label>
                        <div class="layui-input-block">
                            <input name="deliveryTime" id="deliveryTime" placeholder="请选择交货时间" type="text"
                                   class="layui-input" readonly/>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">*</span>合同存放地点</label>
                        <div class="layui-input-block">
                            <input name="address" placeholder="请输入合同存放地点" type="text" class="layui-input"/>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red">*</span>合同保管员</label>
                        <div class="layui-input-block">
                            <select name="keeper"></select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="contractChangeRecordFormSubmit" lay-submit>保存</button>
            </div>
        </form>
    </script>

    <!-- 合同-表格操作列 -->
    <script type="text/html" id="contractChangeRecordTableBar">
        {{# if(d.status == 'stayAudit' || d.status == 'fail'){ }}
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
        {{# } }}
        <a class="layui-btn layui-btn-xs" lay-event="view">详情</a>
        {{# if(d.status == 'stayAudit'){ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="audit">审核</a>
        {{# } }}
        {{# if(d.status == 'success'){ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="final">终版</a>
        {{# } }}
    </script>

    <!-- 合同-终版弹窗 -->
    <script type="text/html" id="contractFinalForm">
        <form lay-filter="contractFinalForm" class="layui-form model-form">
            <input name="id" type="hidden"/>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>交货时间</label>
                <div class="layui-input-block">
                    <input name="deliveryTime" id="deliveryTime" placeholder="请选择交货时间" type="text"
                           class="layui-input" readonly lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>合同存放地点</label>
                <div class="layui-input-block">
                    <input name="address" placeholder="请输入合同存放地点" type="text" class="layui-input"
                           lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>合同保管员</label>
                <div class="layui-input-block">
                    <select name="keeper" lay-verify="required" required lay-search></select>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="contractFinalFormSubmit" lay-submit>确认终版</button>
            </div>
        </form>
    </script>

    <!-- 合同-关联物料 -->
    <script type="text/html" id="contractRelatedProduct">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格 -->
                <table class="layui-table" id="contractRelatedProductContractTable"
                       lay-filter="contractRelatedProductContractTable"></table>

                <!-- 表格 -->
                <table class="layui-table" id="contractRelatedProductTable"
                       lay-filter="contractRelatedProductTable"></table>
            </div>
        </div>
    </script>

    <!-- 合同-联系客户 -->
    <script type="text/html" id="customerPhoneBar">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="viewCustomerPhone">联系客户</a>
    </script>
</div>

<!--尽调管理div-->
<div id="jd">
    <!-- 尽调弹窗 -->
    <script type="text/html" id="dueForm">
        <form lay-filter="dueForm" class="layui-form open-form">
            <div class="open-model">
                <div class="open-auto">
                    <div class="layui-form-item">
                        <button id="dueBtnAdd" class="layui-btn icon-btn" type="button">添加客户尽调记录信息</button>
                    </div>
                    <div class="layui-form-item">
                        <!-- 表格 -->
                        <table class="layui-table" id="dueTable" lay-filter="dueTable"></table>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                </div>
            </div>
        </form>
    </script>


    <!--尽调添加弹窗 -->
    <script type="text/html" id="addDueForm">
        <form lay-filter="addDueForm" class="layui-form open-form">
            <div class="open-model">
                <div class="open-auto" style="padding-top: 10px;">
                    <div class="layui-form-item">
                        <table class="layui-table" id="addDueTable" lay-filter="addDueTable"
                               style="margin: 0"></table>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button id="dueFormSubmit" class="layui-btn" lay-filter="addDueFormSubmit" lay-submit>保存
                    </button>
                </div>
            </div>
        </form>
    </script>


    <!--尽调title-->

    <script type="text/html" id="addDueFormToolbar">
        <a class="layui-btn" lay-event="addDueFormToolbarAdd" style="margin-bottom: 20px;border-radius: 4px;">添加</a>
    </script>

    <!-- 表格操作列 -->
    <script type="text/html" id="dueTableBar">

        {{# if(d.status=='oncheck'){  }}
        <a class="layui-btn layui-btn-xs" lay-event="dueEdit">修改</a>
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="dueCheck">审核</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="dueDel">删除</a>
        {{# }else{ }}
        <a class="layui-btn layui-btn-xs" lay-event="dueDetail">详情</a>
        {{# } }}

    </script>

    <script type="text/html" id="addDueTableBar">
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
    </script>
</div>


<!-- js部分 -->
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<script type="text/javascript" src="../../../admin/assets/js/jsencrypt.min.js"></script>
<script>
    var $, config;

    // 预览文件
    function previewFile(realName, url) {
        $("#attachmentName").text("合同附件：" + realName);
        PDFObject.embed(url, "#example1");
    }

    //下载文件
    function downloadFile(realName, url) {
        var $downForm = $("<form method='get'></form>");
        $downForm.attr("action", config.upload_url + 'downloadFile');
        var $input = $("<input type='hidden'>");
        $input.attr("name", "url");
        $input.val(url);
        $downForm.append($input);
        var $input1 = $("<input type='hidden'>");
        $input1.attr("name", "filename");
        $input1.val(realName);
        $downForm.append($input1);
        var $input2 = $("<input type='hidden'>");
        $input2.attr("name", "access_token");
        var publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCcLt6aJfWmRid+8Cuirv9Zi8sVfhSJ+pUkL7dC+M1yc+e6zr+PQj8sbl2jV5ZBhF4VwoIHWzFLoxNKSizukUNzumJi1KwhjmbASN2EVBKUhJwmx422oew9WCnZYE9+/T+xF87Diie3uQm+7cYVCpvlpqnf9zMBB0Js9zYjOPtP4wIDAQAB";
        var crypt = new JSEncrypt();
        crypt.setKey(publicKey);
        var token = "Bearer " + config.getToken();
        var tokenLeft = token.substring(0, 50);
        var tokenRight = token.substring(50);
        var enc = crypt.encrypt(tokenLeft);
        $input2.val(enc + tokenRight);
        $downForm.append($input2);
        $(document.body).append($downForm);
        //提交表单，实现下载
        $downForm.submit();
    }

    //在Jquery里格式化Date日期时间数据
    function timeStamp2String(time) {
        var datetime = new Date(time);
        var year = datetime.getFullYear();
        var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
        var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
        var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
        var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
        var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
        // return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
        return year + "年" + month + "月" + date + "日";
    }

    layui.use(['layer', 'form', 'table', 'admin', 'upload', 'laydate', 'laytpl'], function () {
        $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var laytpl = layui.laytpl;

        //导入excel
        $('#uploaderInput').on("change", function (e) {
            layer.load(2);
            var formData = new FormData();
            var files = e.target.files;
            let that = $(this);
            formData.append("file", files[0]);
            formData.append("name", files[0].name);//这个地方可以传递多个参数
            $.ajax({
                url: config.base + 'enterprise/sell/admin/customersInfo/importExcel',
                data: formData,
                headers: {Authorization: 'Bearer ' + config.getToken()},
                type: "POST",
                processData: false,
                contentType: false,
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        // table.reload('humanResourcesTable');
                        layer.closeAll('page');
                        setTimeout(_ => {
                            location.reload()
                        }, 1000);
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    that.val('');
                }
            });

        })
        // 模板下载
        $('#fromLocalWarehouseBtnTemplate').click(function () {
            window.location.href = config.base + "enterprise/sell/admin/customersInfo/template";
        });

        // 渲染表格
        var insTb = table.render({
            elem: '#customersInfoTable',
            url: config.base + 'enterprise/sell/admin/customersInfo/list',
            toolbar: true,
            defaultToolbar: ["filter"],
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: '序号'}
                , {field: 'licenseNo', align: 'center', title: '统一社会信用代码', width: 180}
                , {field: 'code', align: 'center', title: '客户编码'}
                , {field: 'customerName', align: 'center', title: '客户名称'}
                , {
                    field: 'region', align: 'center', title: '所在区域', templet: function (d) {
                        d.region = d.provinceName + '/' + d.areaName;
                        return d.region;
                    }
                }
                , {field: 'agentName', align: 'center', title: '所属渠道'}
                , {field: 'contactName', align: 'center', title: '客户代表'}
                , {field: 'customerTypeDesc', align: 'center', title: '客户状态'}
                , {field: 'createTime', align: 'center', title: '合作日期', width: 160}
                , {align: 'center', toolbar: '#customersInfoTableBar', title: '操作', width: 410}
            ]],
            done: function (res, curr, count) {
                //移除按钮
                var menuButton = config.getMenuButton(location.hash);

            }
        });

        // 工具条点击事件
        table.on('tool(customersInfoTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            } else if (obj.event === 'detail') { //详情
                showDetailModel(data);
            } else if (obj.event === 'contact') {//联系人
                showContact(data);
            } else if (obj.event === 'product') {//物料目录
                showProductCatalog(data);
            } else if (obj.event === 'followRecord') {//跟进记录
                showFollowRecord(data);
            } else if (obj.event === 'custContract') {//合同
                showCustomerContract(data);
            } else if (obj.event === 'due') { // 尽调
                showDue(obj);
            }
        });

        //验证
        form.verify({
            contactShot: function (value, item) {
                if (value === '') {
                    return '请上传联系人照片';
                }
            }
        });

        //监听排序
        table.on('sort(customersInfoTable)', function (obj) {
            table.reload('customersInfoTable', {
                initSort: obj
                , where: {
                    sort: obj.field
                    , order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(customerQuery)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

        // 添加按钮点击事件
        $('#customersInfoBtnAdd').click(function () {
            showEditModel();
        });

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '1000px',
                title: data ? '修改客户信息' : '添加客户信息',
                content: $('#customersInfoForm').html(),
                success: function () {
                    if (data) {
                        var option = $("form select[name='customerType']").find("option");
                        layui.each(option, function (index, item) {
                            if (data.customerType == item.text) {
                                data.customerType = item.value;
                            }
                        });
                    }

                    //获取职务
                    admin.req('enterprise/sell/admin/customerContactPost/list', {limit: 999}, (res) => {
                        if (res.code == 200) {
                            loadSelectHtml(res.data, "请选择职务", 'postId', 'name')
                            if (data) {
                                $("#postId").val(data.postId);
                                form.render('select');
                            }
                        }
                    }, 'get');

                    //获取线索来源
                    admin.req('enterprise/sell/admin/customerClueSource/list', {limit: 999}, (res) => {
                        if (res.code == 200) {
                            loadSelectHtml(res.data, "请选择线索来源", 'clueSourceId', 'name')
                            if (data) {
                                $("#clueSourceId").val(data.clueSourceId);
                                form.render('select');
                            }
                        }
                    }, 'get');

                    getUsers(data);//获取审批人/业务员
                    form.on('select(approver)', function (data) {//审批人姓名
                        admin.req('user/admin/user/getUserInfoByUserId', {userId: data.value}, (res) => {
                            if (res.code == '200') {
                                $("#approverNameHidden").val(res.data.nickname);
                            }
                        }, 'GET');
                    });
                    form.on('select(salesman)', function (data) {//业务员姓名
                        admin.req('user/admin/user/getUserInfoByUserId', {userId: data.value}, (res) => {
                            if (res.code == '200') {
                                $("#salesmanNameHidden").val(res.data.nickname);
                            }
                        }, 'GET');
                    });

                    // getAgentInfo();//获取代理商

                    //**设置禁止选择：**//
                    $("#customerType").attr("disabled", "disabled");
                    //$("#customerType").attr("style", "background-color: #EEEEEE;");//设为灰色

                    form.val('customersInfoForm', data);

                    // 获取省区域信息
                    admin.req('enterprise/area/getProvinceList', {}, function (res) {

                        if (200 == res.code) {
                            loadSelectHtml(res.data, "请选择省份", "province", "name");
                        }
                    }, 'POST', true);

                    var selectArea = function (city) {
                        admin.req('enterprise/area/getAreaList?parentId=' + city, {}, function (res) {
                            layer.closeAll('loading');
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择区/县", "area", "name");
                            }
                        }, 'POST');
                    }
                    var selectCity = function (province) {
                        admin.req('enterprise/area/getCityList?parentId=' + province, {}, function (res) {
                            layer.closeAll('loading');
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择市", "city", "name");
                            }
                        }, 'POST');
                    }

                    form.on('select(province)', function (data) {
                        $("#city").empty();
                        $('#area').empty();
                        // 获取市区域信息
                        if (data.value != '') {
                            selectCity(data.value);
                        }
                    });
                    form.on('select(city)', function (data) {
                        $('#area').empty();
                        // 获取区县区域信息
                        if (data.value != '') {
                            selectArea(data.value);
                        }
                    });

                    //上传名片
                    uploadImg("btnUpload15", "btnUpload15_path", "btnUpload15_file");
                    if (data && data.visitingCard) {
                        $('#btnUpload15_path').html('<img src="' + data.visitingCard + '" style="height: 35px;" />');
                    }

                    // 表单提交事件
                    form.on('submit(customersInfoFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprise/sell/admin/customersInfo/update' : 'enterprise/sell/admin/customersInfo/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('customersInfoTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/sell/admin/customersInfo/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        //显示详情弹窗
        function showDetailModel(data) {
            admin.open({
                type: 1,
                area: ['1480px', '800px'],
                title: '详情',
                content: $('#detailTable').html(),
                success: function () {
                    getDetail(data);
                }
            })
        }

        //显示联系人弹窗
        function showContact(data) {
            admin.open({
                type: 1,
                area: ['1480px', '800px'],
                title: '联系人信息',
                content: $('#contactHtml').html(),
                success: function () {
                    contactInfo(data);
                }
            })
        }

        //显示物料目录弹窗
        function showProductCatalog(data) {
            admin.open({
                type: 1,
                area: ['84%', '800px'],
                title: '客户物料目录管理',
                content: $('#productCatalogHtml').html(),
                success: function () {
                    productCatalogInfo(data);
                }
            })
        }

        //显示跟进记录弹窗
        function showFollowRecord(data) {
            admin.open({
                type: 1,
                area: ['1500px', '800px'],
                title: '跟进记录信息',
                content: $('#followRecordHtml').html(),
                success: function () {
                    followRecordInfo(data);
                }
            })
        }

        //显示合同管理弹窗
        function showCustomerContract(data) {
            admin.open({
                type: 1,
                area: ['1540px', '800px'],
                title: '合同信息',
                content: $('#customerContractHtml').html(),
                success: function () {
                    customerContract(data);
                }
            })
        }

        //显示尽调管理弹窗
        function showDue(obj) {
            admin.open({
                type: 1,
                area: ['85%', '85%'],
                title: '尽调管理',
                content: $('#dueForm').html(),
                success: function () {
                    doDue(obj);
                }
            })
        }

        //详情窗口
        function getDetail(data) {
            //渲染正式客户详细信息
            table.render({
                elem: '#customersDetailTable',
                url: config.base + 'enterprise/sell/admin/customersInfo/list?id=' + data.id,
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'licenseNo', align: 'center', title: '统一信用编码', width: 180}
                    , {field: 'customerName', align: 'center', title: '客户名称'}
                    , {
                        field: 'region', align: 'center', title: '所在地', templet: function (d) {
                            d.region = d.provinceName + '/' + d.areaName;
                            return d.region;
                        }
                    }
                    , {field: 'contactName', align: 'center', title: '联系人'}
                    , {
                        field: 'contactWay', align: 'center', title: '联系方式', templet: function (d) {
                            if (d.telephone != null && d.telephone != "") {
                                return d.telephone;
                            } else {
                                if (d.wechatNumber != null && d.wechatNumber != "") {
                                    return d.wechatNumber;
                                }
                                if (d.email != null && d.email != "") {
                                    return d.email;
                                }
                            }

                        }
                    }
                    , {field: 'agentName', align: 'center', title: '渠道服务商'}
                    , {field: 'salesmanName', align: 'center', title: '业务员'}
                    , {field: 'createTime', align: 'center', title: '创建时间', width: 180}

                ]],
                done: function (res, curr, count) {
                    //移除按钮
                }
            });
            // 客户基本信息
            admin.req('enterprise/sell/admin/agent/list', {limit: 99999, status: '2,3'}, (res) => {
                if (res.code == '200' && res.data.length > 0) {
                    form.val('customersDetailForm', res.data[0]);
                    if (res.data[0] && res.data[0].licensePhoto) {
                        $('#licensePhoto').html('<img src="' + res.data[0].licensePhoto + '" style="max-width: 196px"><input type="hidden" name="licensePhoto" value="' + res.data[0].licensePhoto + '" />');
                    }

                    if (res.data[0] && res.data[0].openingPermit) {
                        $('#license').html('<img src="' + res.data[0].openingPermit + '" style="max-width: 196px"><input type="hidden" name="license" value="' + res.data[0].openingPermit + '" />');
                    }
                    layer.photos({
                        photos: '.uploadImgStyle'
                        , anim: 5
                    });
                }
            }, 'GET');
            //客户联系人信息
            contactInfo(data);
            //财务信息
            billOrdInfo();
            //跟进记录
            followRecordInfo(data);
            //客户线索信息
            customerLeadsInfo(data);


        }

        //客户联系人信息
        function contactInfo(data) {
            var insTb = table.render({
                elem: '#contactInfoTable,#contactInfoTable2',
                url: config.base + 'enterprise/sell/admin/contactInfo/list',
                where: {selCustomerId: data.id},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'name', align: 'center', title: '联系人姓名'}
                    , {field: 'sexDesc', align: 'center', title: '性别'}
                    , {field: 'postName', align: 'center', title: '职务'}
                    , {field: 'department', align: 'center', title: '所属部门'}
                    , {field: 'telephone', align: 'center', title: '电话'}
                    , {field: 'email', align: 'center', title: '邮箱'}
                    , {field: 'remark', align: 'center', title: '备注'}
                    , {field: 'creatorName', align: 'center', title: '创建人'}
                    , {field: 'createTime', align: 'center', title: '创建时间', width: 180}
                    , {align: 'center', toolbar: '#contactInfoTableBar', title: '操作'}
                ]],
            });
            // 工具条点击事件
            table.on('tool(contactInfoTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') { //修改
                    showContactEditModel(data);
                } else if (obj.event === 'del') { // 删除
                    doDelete(obj);
                }
            });

            //监听排序
            table.on('sort(contactInfoTable)', function (obj) {
                table.reload('contactInfoTable', {
                    initSort: obj
                    , where: {
                        sort: obj.field
                        , order: obj.type
                    }
                });
            });

            // 搜索
            form.on('submit(formSubSearchLog)', function (data) {
                insTb.reload({where: data.field, page: {curr: 1}}, 'data');
            });

            // 添加按钮点击事件
            $('#contactInfoBtnAdd,#contactInfoBtnAdd2').click(function () {
                showContactEditModel(null, data.id);
            });

            // 显示联系人编辑弹窗
            function showContactEditModel(data, selCustomerId) {
                admin.open({
                    type: 1,
                    area: '820px',
                    title: data ? '修改客户联系人信息' : '添加客户联系人信息',
                    content: $('#contactInfoForm').html(),
                    success: function () {
                        //获取职务
                        admin.req('enterprise/sell/admin/customerContactPost/list', {limit: 999}, (res) => {
                            if (res.code == 200) {
                                loadSelectHtml(res.data, "请选择职务", 'postId', 'name')
                                if (data) {
                                    $("#contactPostId").val(data.postId);
                                    form.render('select');
                                }
                            }
                        }, 'get');

                        form.val('contactInfoForm', data);

                        // 获取客户数据
                        admin.req('enterprise/sell/admin/customersInfo/list', {limit: 9999}, function (res) {
                            if (res.code == 200) {
                                var html = '<option value="">请选择所属客户</option>';
                                for (var k = 0; k < res.data.length; k++) {
                                    html += '<option value="' + res.data[k].id + '">' + res.data[k].customerName + '</option>';
                                }
                                $("form select[name='selCustomerId']").html(html);
                                if (data && data.selCustomerId) {
                                    form.val('contactInfoForm', data);
                                }
                                if (selCustomerId) {
                                    form.val('contactInfoForm', {selCustomerId: selCustomerId});
                                }
                                form.render('select');

                            } else {
                                layer.msg('获取客户失败', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        //上传联系人照片
                        upload.render({
                            elem: '#btnUpload14'
                            , url: config.upload_url + 'upload?path=' + img_path
                            , data: {}
                            , accept: 'file'
                            , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                            , headers: {authorization: 'Bearer ' + config.getToken()}
                            , done: function (res) {
                                if (res.code == 200) {

                                    layer.msg(res.msg || "上传成功", {icon: 1});
                                    var imagUrl = res.data.url;
                                    $('#btnUpload14_path').html('<img src="' + imagUrl + '" style="height: 35px;" />');
                                    $('#btnUpload14_file').val(imagUrl);
                                } else if (res.code == 502) {
                                    return location.replace('admin/login.html');
                                } else {
                                    layer.msg(res.msg || "上传失败", {icon: 2});
                                }
                            }
                        });

                        if (data && data.picture) {
                            $('#btnUpload14_path').html('<img src="' + data.picture + '" style="height: 35px;" />');
                        }

                        //上传名片
                        upload.render({
                            elem: '#btnUpload16'
                            , url: config.upload_url + 'upload?path=' + img_path
                            , data: {}
                            , accept: 'file'
                            , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                            , headers: {authorization: 'Bearer ' + config.getToken()}
                            , done: function (res) {
                                if (res.code == 200) {

                                    layer.msg(res.msg || "上传成功", {icon: 1});
                                    var imagUrl = res.data.url;
                                    $('#btnUpload16_path').html('<img src="' + imagUrl + '" style="height: 35px;" />');
                                    $('#btnUpload16_file').val(imagUrl);
                                } else if (res.code == 502) {
                                    return location.replace('admin/login.html');
                                } else {
                                    layer.msg(res.msg || "上传失败", {icon: 2});
                                }
                            }
                        });
                        if (data && data.visitingCard) {
                            $('#btnUpload16_path').html('<img src="' + data.visitingCard + '" style="height: 35px;" />');
                        }

                        // 表单提交事件
                        form.on('submit(contactInfoFormSubmit)', function (d) {
                            layer.load(2);
                            admin.req(data ? 'enterprise/sell/admin/contactInfo/update' : 'enterprise/sell/admin/contactInfo/add', d.field, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('contactInfoTable');
                                    layer.closeAll('page');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, data ? 'PUT' : 'POST');
                            return false;
                        });
                    }
                });
            }
        }

        //财务信息
        function billOrdInfo() {
            //时间范围
            laydate.render({
                elem: '#pTimeBill',
                type: 'date',
                range: true,
                done: function (value, date, endDate) {
                    var dateValue = value.split(" - ");
                    $("#sTimeBill").val(dateValue[0]);
                    $("#eTimeBill").val(dateValue[1]);
                }
            });
            //渲染表格
            var billTb = table.render({
                elem: '#billTable',
                url: config.base + 'enterprisecab/bill/admin/billOrdInformation/list',
                page: true,
                cellMinWidth: 130,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'billNo', align: 'center', title: '账单编号', width: 170}
                    , {field: 'startTime', align: 'center', title: '账单开始时间', width: 160}
                    , {field: 'endTime', align: 'center', title: '账单结束时间', width: 160}
                    , {field: 'billOrdAmount', align: 'center', title: '子订单数', width: 100}
                    , {field: 'billTotalMoney', align: 'center', title: '账单总金额'}
                    , {field: 'createTime', align: 'center', title: '生成时间', width: 160}
                    , {field: 'billStatusDesc', align: 'center', title: '状态'}
                    , {field: 'invoiceStatusDesc', align: 'center', title: '开票状态'}
                    , {field: 'billAuditor', align: 'center', title: '审核人'}
                    , {align: 'center', toolbar: '#billTableBar', title: '操作', width: 240}
                ]]
            });

            // 工具条点击事件
            table.on('tool(billTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'details') { //详情
                    showBillDetails(data);
                } else if (obj.event === 'viewBillBtn') { // 确认
                    showViewBill(data);
                } else if (obj.event === 'settlementInfoBtn') { //結算信息
                    showSettlementInfoView(data);
                } else if (obj.event === 'invoiceInfoBtn') { // 发票信息
                    showInvoiceInfo(data);
                }
            });

            // 搜索
            form.on('submit(formSearch)', function (data) {
                billTb.reload({where: data.field, page: {curr: 1}});
            });

            //重置
            $('#formResets').click(() => {
                $("#sTime").val("");
                $("#eTime").val("");
            });

            //详情弹窗
            function showBillDetails(data) {
                admin.open({
                    type: 1,
                    area: ['1540px', '800px'],
                    title: '详情',
                    content: $('#billDetails').html(),
                    success: function () {
                        //柜子业务月度统计
                        admin.req('enterprisecab/bill/admin/billOrdInformation/billCensusDetail', {'billNo': data.billNo}, (res) => {
                            if (res.code == '200') {
                                $('#xq_billTotalMoney').text(res.data.totalMoney);
                                $('#xq_billOrdAmount').text(res.data.amount);
                                $('#xq_billSettledMoney').text(res.data.settled);
                                $('#xq_billNosettledMoney').text(res.data.noSettled);
                                $('#xq_billInvoicedMoney').text(res.data.invoiced);
                                $('#xq_billNoinvoicedMoney').text(res.data.pending);
                            } else {
                                $('#xq_billTotalMoney').text('');
                                $('#xq_billOrdAmount').text('');
                                $('#xq_billSettledMoney').text('');
                                $('#xq_billNosettledMoney').text('');
                                $('#xq_billInvoicedMoney').text('');
                                $('#xq_billNoinvoicedMoney').text('');
                            }
                        }, 'GET')

                        // 收款账户信息
                        admin.req('enterprisecab/bill/admin/billOrdInformation/list', {'billNo': data.billNo}, (res) => {
                            if (res.code == '200' && res.data.length > 0) {
                                form.val('moneyCollectAccountInfoForm', res.data[0]);
                            }
                        }, 'GET');

                        // 结算信息
                        admin.reqSync('enterprisecab/bill/admin/billOrdPayInformation/list', {'billNo': data.billNo}, (res) => {
                            if (res.code == '200' && res.data.length > 0) {
                                form.val('settlementInformationForm', res.data[0]);

                                $('#payFile_path').html('<img src="' + res.data[0].payFile + '">')
                                $('#payMoneySpan').text(res.data[0].payMoney);
                                $('#payMoneyBtn').show();
                            }
                        }, 'GET');

                        admin.reqSync('enterprisecab/bill/admin/billOrdInvoiceInformation/list', {'billNo': data.billNo}, (res) => {
                            if (res.code == '200' && res.data.length > 0) {
                                form.val('invoiceInfoForm', res.data[0]);
                                res.data[0].count = res.count + "张";
                                $('#countSpan').text(res.data[0].count);
                                $('#countBtn').show();
                                $('#xq_invoiceFile_path').html('<img src="' + res.data[0].invoiceFile + '">');
                            }
                        }, 'GET');

                        layer.photos({
                            photos: '.uploadImgStyle'
                            , anim: 5
                        });
                        $('#countBtn').click(_data => {
                            showInvoiceInfo(data);
                        });
                        $("#payMoneyBtn").click(_data => {
                            showSettlementInfoView(data);
                        });

                        let billDetailsFormTb = table.render({
                            elem: '#billDetailsTable',
                            url: config.base + 'enterprisecab/bill/admin/billOrdInformationDetail/list?billNo=' + data.billNo,
                            page: true,
                            cols: [[
                                {type: 'numbers'}
                                , {field: 'ordNo', align: 'center', title: '订单编号', width: 160}
                                , {field: 'productName', align: 'center', title: '领用物料名称', width: 180}
                                , {field: 'quantity', align: 'center', title: '领取数量'}
                                , {field: 'price', align: 'center', title: '单价'}
                                , {field: 'totalMoney', align: 'center', title: '总价'}
                                , {field: 'cabCode', align: 'center', title: '所属柜子'}
                                , {field: '', align: 'center', title: '所在车间'}
                                , {field: 'receiver', align: 'center', title: '领用人'}
                                , {field: 'deviceName', align: 'center', title: '使用台机'}
                                , {field: 'collectTime', align: 'center', title: '领用时间', width: 160}
                                , {field: 'statusDesc', align: 'center', title: '状态'}
                                , {field: 'createTime', align: 'center', title: '账单时间', width: 160}
                            ]]
                        });
                    }
                })
            }

            // 显示确认界面
            function showViewBill(data) {
                admin.open({
                    type: 1,
                    area: ['1240px', '800px'],
                    offset: '65px',
                    title: '确认账单',
                    content: $('#viewBill').html(),
                    success: function () {
                        data.confirmResult = data.confirmResult ? data.confirmResult : "";
                        form.val('viewBillForm', data);
                        let meIsShow = false, OtherPartyIsShow = false;
                        form.render('select');
                        form.on("select(confirmResult)", function (data) {
                            if (data.value == 'pass') {
                                $('#confirmRefuseRemarkBox').hide();
                            } else if (data.value == 'refuse') {
                                $('#confirmRefuseRemarkBox').show();
                            } else {
                                $('#confirmRefuseRemarkBox').hide();
                            }
                        });
                        $('#viewBillMeModifyBtn').click(() => {
                            meIsShow = !meIsShow;
                            if (meIsShow) {
                                $('#viewBillMeModifyBtn').text('保存');
                                $('#viewBillMeModifyBtn').parent().prev().find('input').removeAttr('readonly');
                                $('#viewBillMeModifyBtn').parent().prev().find('input').css('border', '1px solid #D9D9D9');
                            } else {
                                $('#viewBillMeModifyBtn').text('修改');
                                $('#viewBillMeModifyBtn').parent().prev().find('input').attr('readonly');
                                $('#viewBillMeModifyBtn').parent().prev().find('input').css('border', 'none');
                            }

                        });
                        $('#viewBillOtherPartyModifyBtn').click(() => {
                            OtherPartyIsShow = !OtherPartyIsShow;
                            if (OtherPartyIsShow) {
                                $('#viewBillOtherPartyModifyBtn').text('保存');
                                $('#viewBillOtherPartyModifyBtn').parent().prev().find('input').removeAttr('readonly');
                                $('#viewBillOtherPartyModifyBtn').parent().prev().find('input').css('border', '1px solid #D9D9D9');
                            } else {
                                $('#viewBillOtherPartyModifyBtn').text('修改');
                                $('#viewBillOtherPartyModifyBtn').parent().prev().find('input').attr('readonly');
                                $('#viewBillOtherPartyModifyBtn').parent().prev().find('input').css('border', 'none');
                            }
                        })

                        form.on("submit(viewBillSubmit)", (d) => {
                            d.field.examResult = d.field.examineResult;
                            admin.req('enterprisecab/bill/admin/billOrdInformation/confirmBill', d.field, res => {
                                if (res.code == '200') {
                                    layer.msg(res.msg, {'icon': 1});
                                    layer.closeAll();
                                    table.reload('billTable');
                                } else {
                                    layer.msg(res.msg, {'icon': 2});
                                }
                            }, 'PUT')
                        })


                    }
                })
            }


            //结算信息
            let isState = false;

            function showSettlementInfoView(data) {
                admin.open({
                    type: 1,
                    area: '1400px',
                    title: '结算信息',
                    content: $('#settlementInfoView').html(),
                    success: function () {

                        // 添加支付凭证信息
                        $('#addPaymentInfo').click(() => {
                            isState = false;
                            data.remark = undefined;
                            showSettlementInfoDetails(data);
                        })
                        form.render('select');
                        //时间范围
                        laydate.render({
                            elem: '#settlementInfo_pTime',
                            type: 'date',
                            range: true,
                            done: function (value, date, endDate) {
                                var dateValue = value.split(" - ");
                                $("#settlementInfo_sTime").val(dateValue[0]);
                                $("#settlementInfo_eTime").val(dateValue[1]);
                            }
                        });

                        //渲染表格
                        var settlementInfoViewTb = table.render({
                            elem: '#settlementInfoViewTable',
                            url: config.base + 'enterprisecab/bill/admin/billOrdPayInformation/list?billNo=' + data.billNo,
                            page: true,
                            cellMinWidth: 130,
                            cols: [[
                                {type: 'numbers', title: '序号'}
                                , {
                                    field: 'payFile',
                                    align: 'center',
                                    title: '结算凭证',
                                    templet: d => "<img src='" + d.payFile + "'/>"
                                }
                                , {field: 'payFileNo', align: 'center', title: '凭证编码'}
                                , {field: 'billNo', align: 'center', title: '所属账单', width: 160}
                                , {field: 'incomeAccount', align: 'center', title: '收款企业名称', width: 180}
                                , {field: 'payMoney', align: 'center', title: '支付金额'}
                                , {field: 'payNumber', align: 'center', title: '支付账号'}
                                , {field: 'payName', align: 'center', title: '支付人'}
                                , {field: 'createTime', align: 'center', title: '支付时间', width: 160}
                                , {align: 'center', toolbar: '#settlementInfoBar', title: '操作'}
                            ]]
                        });
                        //    工具条事件
                        table.on('tool(settlementInfoViewTable)', function (obj) {
                            var _data = obj.data;
                            if (obj.event === 'settlementInfoDetailsBtn') { //详情
                                isState = true;
                                showSettlementInfoDetails(_data);
                            }
                        });

                        //    搜索
                        //    settlementInfoViewFormSearch
                        form.on('submit(settlementInfoViewFormSearch)', function (data) {
                            settlementInfoViewTb.reload({where: data.field, page: {curr: 1}});
                        });
                    }
                })
            }

            //結算信息 支付凭证信息和详情弹窗
            function showSettlementInfoDetails(data) {
                let settlementInfoDetailsForm = admin.open({
                    type: 1,
                    area: ['1240px', '800px'],
                    title: isState ? '结算信息详情' : "添加支付凭证信息",
                    content: $('#settlementInfoDetails').html(),
                    success: function () {
                        if (isState) {
                            $(".settlementInfoDetails input").css('border', 'none');
                            $(".settlementInfoDetails input").attr('readonly', 'readonly');
                            $(".settlementInfoDetails select").css('border', 'none');
                            $(".settlementInfoDetails select").attr('disabled', 'disabled');
                            $(".settlementInfoDetails textarea").attr('disabled', 'disabled');
                            $("#settlementInfoDetailsSubmitBox").hide();
                            $("#devicePicBtn").hide();
                            $('#devicePic_path').html('<img src="' + data.payFile + '"/>');
                            form.val('settlementInfoDetailsForm', data);
                        } else {
                            form.val('settlementInfoDetailsForm', data);
                            $('#devicePicBtn').click(uploadImg('devicePicBtn', 'devicePic_path', 'payFile'));
                            form.on('select(transferor)', data => {
                                if (data.value == 'self') {
                                    $('#payNameBox').hide();
                                    $('#payName').val('');
                                } else {
                                    $('#payNameBox').show();
                                }
                            })

                            form.on('submit(settlementInfoDetailsSubmit)', (d) => {
                                d.field.incomeAccount = data.incomeAccount;
                                d.field.incomeBank = data.incomeBank;
                                d.field.incomeNumber = data.incomeNumber;
                                d.field.type = data.type;
                                admin.req('enterprisecab/bill/admin/billOrdPayInformation/addAll', d.field, res => {
                                    if (res.code == '200') {
                                        layer.msg(res.msg, {'icon': 1});
                                        layer.close(settlementInfoDetailsForm);
                                        table.reload('settlementInfoViewTable');
                                    } else {
                                        layer.msg(res.msg, {'icon': 2});
                                    }
                                }, 'POST')
                            })
                        }
                        // uploadImgStyle
                        layer.photos({
                            photos: '.uploadImgStyle'
                            , anim: 5
                        });
                        form.render('select');

                    }
                });
            }

            //发票信息
            function showInvoiceInfo(data) {
                admin.open({
                    type: 1,
                    area: '1400px',
                    title: "账单发票信息",
                    content: $('#invoiceInfoView').html(),
                    success: function () {
                        form.render('select');
                        //时间范围
                        laydate.render({
                            elem: '#invoiceInfo_pTime',
                            type: 'date',
                            range: true,
                            done: function (value, date, endDate) {
                                let dateValue = value.split(" - ");
                                $("#invoiceInfo_sTime").val(dateValue[0]);
                                $("#invoiceInfo_eTime").val(dateValue[1]);
                            }
                        });

                        //渲染表格
                        var invoiceInfoViewTb = table.render({
                            elem: '#invoiceInfoViewTable',
                            url: config.base + 'enterprisecab/bill/admin/billOrdInvoiceInformation/list?billNo=' + data.billNo,
                            page: true,
                            cellMinWidth: 130,
                            cols: [[
                                {type: 'numbers', title: '序号'}
                                , {
                                    field: 'invoiceFile',
                                    align: 'center',
                                    title: '发票凭证',
                                    templet: d => "<img src='" + d.invoiceFile + "'/>"
                                }
                                , {field: 'invoiceNo', align: 'center', title: '发票编码'}
                                , {field: 'billNo', align: 'center', title: '所属账单', width: 160}
                                , {field: 'enterpriseName', align: 'center', title: '开票企业名称', width: 160}
                                , {field: 'invoiceMoney', align: 'center', title: '开票金额', width: 100}
                                , {field: 'taxRate', align: 'center', title: '税率', width: 100}
                                , {field: 'taxMoney', align: 'center', title: '税额', width: 100}
                                , {field: 'drawer', align: 'center', title: '开票人', width: 100}
                                , {field: 'createTime', align: 'center', title: '创建时间', width: 160}
                                , {align: 'center', toolbar: '#invoiceInfoViewBar', title: '操作'}
                            ]]
                        });
                        //    工具条事件
                        table.on('tool(invoiceInfoViewTable)', function (obj) {
                            var data = obj.data;
                            if (obj.event === 'invoiceInfoViewDetailsBtn') { //详情
                                showInvoiceInfoDetails(data);
                            }
                        });
                        //    搜索
                        form.on('submit(invoiceInfoViewFormSearch)', function (data) {
                            invoiceInfoViewTb.reload({where: data.field, page: {curr: 1}});
                        });

                    }
                })
            }

            //账单信息详情
            function showInvoiceInfoDetails(data) {
                admin.open({
                    type: 1,
                    area: ['1240px', '800px'],
                    title: "账单信息详情",
                    content: $('#invoiceInfoDetails').html(),
                    success: function () {
                        form.val('invoiceInfoDetailsForm', data);
                        $("#invoiceFile_path").html('<img src="' + data.invoiceFile + '">');
                        form.render('select');
                        layer.photos({
                            photos: '.uploadImgStyle'
                            , anim: 5
                        });
                    }
                })
            }

        }

        //物料目录
        function productCatalogInfo(c_data) {
            // 渲染表格
            var insTb = table.render({
                elem: '#customerProductCatalogTable',
                url: config.base + 'enterprise/sell/admin/customerProductCatalog/list',
                where: {customerId: c_data.id},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'cusSkuCode', align: 'center', title: '客户物料料号编码', width: 150}
                    , {field: 'cusProductName', align: 'center', title: '客户物料名称', width: 140}
                    , {field: 'proTypeName', align: 'center', title: '内部物料类型', width: 140}
                    , {field: 'productDetailId', align: 'center', title: '内部物料料号', width: 140}
                    , {
                        field: 'hasPack', align: 'center', title: '是否需要包装', width: 120, templet: function (d) {
                            if (d.hasPack) {
                                return '需要'
                            }
                            return '不需要'
                        }
                    }
                    , {field: 'packInstructions', align: 'center', title: '包装方式'}
                    , {field: 'unitName', align: 'center', title: '单位'}
                    , {
                        field: 'enclosure', align: 'center', title: '附件',
                        templet: '<div><img src="{{ d.enclosure}}"></div>'
                    }
                    , {field: '', align: 'center', title: '单价'}
                    , {field: 'remark', align: 'center', title: '备注'}
                    // , {align: 'center', toolbar: '#customerProductCatalogTableBar', title: '操作', width: 80}
                ]],
                done: function (res, curr, count) {

                }
            });
            table.resize("customerProductCatalogTable");

            table.render({
                elem: '#customerTable',
                url: config.base + 'enterprise/sell/admin/customersInfo/list?id=' + c_data.id,
                page: false,
                cellMinWidth: 100,
                cols: [[
                    {field: 'customerName', align: 'center', title: '客户名称'}
                    , {field: 'id', align: 'center', title: '客户编码'}
                    , {field: 'contactName', align: 'center', title: '客户联系人'}
                    , {field: 'agentName', align: 'center', title: '所属渠道'}
                    , {field: 'createTime', align: 'center', title: '录入时间'}
                    , {field: 'creatorName', align: 'center', title: '客服代表'}
                ]],
                done: function (res, curr, count) {

                }
            });
            table.resize("customerTable");

            // 工具条点击事件
            table.on('tool(customerProductCatalogTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') { //修改
                    showEditModel(data);
                } else if (obj.event === 'del') { // 删除
                    doDelete(obj);
                } else if (obj.event === 'detail') {//详情
                    showAddCustomerProduct(data);
                }
            });

            //监听排序
            table.on('sort(customerProductCatalogTable)', function (obj) {
                table.reload('customerProductCatalogTable', {
                    initSort: obj
                    , where: {
                        sort: obj.field
                        , order: obj.type
                    }
                });
            })

            // 添加物料按钮点击事件
            $('#customerProductCatalogBtnAdd').click(() => {
                admin.formOpen({
                    area: ['90%', '85%'],
                    offset: ['5%', '5%'],
                    title: "修改",
                    path: 'components/sell/customerProductCatalogUserForm.html',
                    success: function () {
                        parentData.data = table.cache['customerTable'][0]
                        parentData.eventName = 'userAdd'
                    }
                })
                // showAddCustomerProduct();
            });

            // 添加物料
            function showAddCustomerProduct(data) {
                admin.open({
                    type: 1,
                    area: ["1580px", '750px'],
                    title: data ? '详情' : '添加物料',
                    content: $('#addCustomerProduct').html(),
                    success: function () {
                        let addCustomerProductListData = [], specificationCode = [];
                        let cacheParameters = {productTypeId: ''}; //保存请求参数,防止同一参数多次请求

                        //客户信息
                        table.render({
                            elem: '#customerTable2',
                            url: config.base + 'enterprise/sell/admin/customersInfo/list',
                            where: {id: c_data.id},
                            page: false,
                            cellMinWidth: 100,
                            cols: [[
                                {field: 'customerName', align: 'center', title: '客户名称'}
                                , {field: 'id', align: 'center', title: '客户编码'}
                                , {
                                    field: '',
                                    align: 'center',
                                    title: '客户联系人',
                                    templet: '#contactNameTemplate',
                                    width: 200
                                }
                                , {field: 'agentName', align: 'center', title: '所属渠道'}
                                , {field: 'createTime', align: 'center', title: '录入时间'}
                                , {field: 'creatorName', align: 'center', title: '客服代表'}
                            ]],
                            done: function (res, curr, count) {
                                //客户联系人
                                admin.req('enterprise/sell/admin/contactInfo/list', {selCustomerId: c_data.id}, function (res) {
                                    if (res.code == 200) {
                                        loadSelectHtml(res.data, "请选择客户联系人", "contactId", "name");
                                    }
                                }, 'GET');
                            }
                        });

                        $("#ggmInp").hide();//隐藏规格码input div

                        //请求物料类型
                        admin.req('enterprise/product/admin/productType/getProductTypeByType', {type: 0}, function (res) {
                            loadSelectHtml(res.data, "请选择物料类型", "productTypeId", "name");

                            if (data) {//回显值
                                $("#productTypeId").val(data.productTypeId);
                                form.render('select');

                                //加载基础单位
                                admin.req('enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType', {
                                    type: 0,
                                    productTypeId: data.productTypeId
                                }, function (res) {
                                    $("#unitId").val(res.data.id);
                                    $("#unitName").val(res.data.name);
                                }, 'get');


                                //包装单位
                                admin.req('enterprise/product/admin/productUnit/getProductUnitByType', {
                                    type: 0,
                                    productTypeId: data.productTypeId
                                }, function (res) {
                                    loadSelectHtml(res.data, "请选择包装单位", "packUnitId", "name");
                                    if (data) {
                                        $("#packUnitId").val(data.packUnitId);
                                        form.render('select');
                                    }
                                }, 'get');

                                //包装方案
                                admin.req('enterprise/product/admin/productPack/getByProductTypeId', {
                                    type: 0,
                                    productTypeId: data.productTypeId
                                }, function (res) {
                                    loadSelectHtml(res.data, "请选择", "productPack", "name");
                                    if (data) {
                                        $("#productPack").val(data.productPack);
                                        form.render('select');
                                    }
                                }, 'get');


                                //客户联系人
                                admin.req('enterprise/sell/admin/contactInfo/list', {
                                    selCustomerId: data.customerId,
                                    id: data.contactId
                                }, function (res) {
                                    loadSelectHtml(res.data, "请选择", "contactId", "name");
                                    $("#contactId").val(data.contactId);
                                    form.render('select');
                                }, 'GET');

                                $("input[name='remark']").val(data.remark);
                                $("input[name='skuCode']").val(data.skuCode);
                                $("input[name='skuName']").val(data.skuName);
                                $("input[name='weight']").val(data.weight);

                                //客户物料信息
                                $("input[name='extProductName']").val(data.extProductName);
                                $("input[name='extProductCode']").val(data.extProductCode);
                                $("input[name='extSpecCode']").val(data.extSpecCode);

                                if (data.packing) {
                                    let select = 'dd[lay-value=0]';
                                    $('#packing').siblings("div.layui-form-select").find('dl').find(select).click();
                                } else {
                                    let select = 'dd[lay-value=1]';
                                    $('#packing').siblings("div.layui-form-select").find('dl').find(select).click();
                                }

                                $("input[name='packingRequire']").val(data.packingRequire);

                                //**设置禁止选择：**//
                                $("#packing").attr("disabled", "disabled");
                                $(".customClass").attr("disabled", "disabled");
                                $(".customClass").attr("style", "background-color: #EEEEEE;");//设置input为灰色背景

                                $("#categoryDiv").css("pointer-events", "none");//物料分类禁选

                                $("#btnUploadExt").hide();//隐藏上传按钮
                                $("#addCustomerProductSubmit").hide();//隐藏提交按钮

                                $("#ggm").hide();//隐藏规格码 table div
                                $("#ggmInp").show();//显示规格码 input div
                                $("#specValueNames").val(data.skuSpecValueNames);
                                $("#specValueNames").show();

                            }
                        }, 'get');

                        form.on('select(productTypeId)', function (data) {
                            //加载基础单位
                            admin.req('enterprise/product/admin/productUnit/getIsBaseUnitProductUnitByType', {
                                type: 0,
                                productTypeId: data.value
                            }, function (res) {
                                $("#unitId").val(res.data.id);
                                $("#unitName").val(res.data.name);
                            }, 'get');

                            //包装单位
                            admin.req('enterprise/product/admin/productUnit/getProductUnitByType', {
                                type: 0,
                                productTypeId: data.value
                            }, function (res) {
                                console.log(res.data);
                                loadSelectHtml(res.data, "请选择", "packUnitId", "name");
                                if (data) {
                                    $("#packUnitId").val(data.packUnitId);
                                    form.render('select');
                                }
                            }, 'get');

                            //包装方案
                            admin.req('enterprise/product/admin/productPack/getByProductTypeId', {productTypeId: data.value}, function (res) {
                                loadSelectHtml(res.data, "请选择", "productPack", "name");
                                if (data) {
                                    $("#productPack").val(data.productPack);
                                    form.render('select');
                                }
                            }, 'get');

                            if (cacheParameters.productTypeId == $("#productTypeId").val()) {
                                addCustomerProductListData = [];
                                addCustomerProductListData.push({
                                    index: 1,
                                    isShow: true,
                                    specificationCode: specificationCode,
                                    skuSpecValueNames: []
                                })
                            } else {
                                cacheParameters.productTypeId = $('#productTypeId').val();
                                addCustomerProductListData = [];
                                //规格数据
                                admin.reqSync('enterprise/product/admin/productSpec/getProductSpecByProductTypeId', {productTypeId: data.value}, res => {
                                    if (res.code === 200) {
                                        specificationCode = res.data;
                                    }
                                }, 'get');

                                addCustomerProductListData.push({
                                    index: 1,
                                    isShow: true,
                                    specificationCode: specificationCode,
                                    skuSpecValueNames: []
                                })
                            }

                            table.reload('specValue', {data: addCustomerProductListData});
                            console.log("addCustomerProductListData:" + addCustomerProductListData);

                        });

                        //物料系列
                        admin.req('enterprise/product/admin/product/list', {}, function (res) {
                            loadSelectHtml(res.data, "请选择物料系列", "productRange", "name");
                            if (data) {
                                $("#productRange").val(data.productRange);
                                form.render('select');

                                admin.req('enterprise/product/admin/product/getProductById', {productId: data.productRange}, function (res) {
                                    $("#rangeCode").val(res.data.productCode)
                                }, 'get');
                            }
                        });
                        //物料系列编码
                        form.on('select(productRange)', function (data) {
                            admin.req('enterprise/product/admin/product/getProductById', {productId: data.value}, function (res) {
                                $("#rangeCode").val(res.data.productCode)
                            }, 'get');
                        });

                        //规格码
                        let addSelfCollectedGoodsTbList = table.render({
                            elem: '#specValue',
                            page: false,
                            cellMinWidth: 110,
                            data: addCustomerProductListData,
                            limit: Number.MAX_VALUE,
                            height: 180,
                            cols: [[
                                {
                                    field: '', width: '500', templet: d => {
                                        let selectHTML = '', skuSpecValueNamesValue = '', skuSpecValueNamesString = '';
                                        d.skuSpecValueNames.forEach(item => skuSpecValueNamesString += item.name + '-');
                                        selectHTML += `<span id="skuSpan" style="display:${d.isShow == true ? 'none' : ''}">${skuSpecValueNamesString.substring(0, skuSpecValueNamesString.length - 1)}</span>`;

                                        d.specificationCode.forEach((item, index) => {
                                            let skuSpecValueNamesValueSelect = '';
                                            selectHTML += `<div class="skuSpecValueNames" style="width: calc((100% - 30px) / 3);float: left;margin:5px; display:${d.isShow == true ? '' : 'none'}">
                                                       <select class="skuSpecValueNamesList"  name="${d.index + '-' + item.id}" id="${d.index + '-' + item.id}" style="margin-bottom: 5px" lay-search="">`;
                                            selectHTML += '<option value="">' + item.name + '</option>';
                                            if (d.skuSpecValueNames[index]) {
                                                skuSpecValueNamesValue = d.skuSpecValueNames[index].value;
                                            } else {
                                                skuSpecValueNamesValue = '';
                                            }
                                            item.productSpecValueList.forEach(itemList => {
                                                if (skuSpecValueNamesValue == itemList.id) {
                                                    skuSpecValueNamesValueSelect = 'selected=""'
                                                } else {
                                                    skuSpecValueNamesValueSelect = ''
                                                }
                                                if (item.specCode == 'is') {
                                                    if (item.specLocation == 'last') {
                                                        selectHTML += '<option ' + skuSpecValueNamesValueSelect + ' value="' + itemList.id + '" skuSpec="' + item.id + '" >' + itemList.value + item.specHead + '</option>'
                                                    } else {
                                                        selectHTML += '<option ' + skuSpecValueNamesValueSelect + ' value="' + itemList.id + '" skuSpec="' + item.id + '" >' + item.specHead + itemList.value + '</option>'
                                                    }

                                                } else {
                                                    selectHTML += '<option ' + skuSpecValueNamesValueSelect + ' value="' + itemList.id + '" skuSpec="' + item.id + '" >' + itemList.value + '</option>'
                                                }
                                            });

                                            selectHTML += '</select></div>';

                                        });
                                        return selectHTML;
                                    }
                                }
                            ]],
                            done: function (res, curr, count) {

                            }
                        });


                        //加载物料分类树级菜单
                        var arr2tree;
                        admin.req('enterprise/product/admin/productCategory/getProductCategoryByType', {type: 0}, function (res) {
                            for (let i = 0; i < res.data.length; i++) {
                                res.data[i].children = [];
                            }
                            arr2tree = xmSelect.arr2tree(res.data, "parentId", "id", "children", -1);
                        }, 'get', false);

                        var selectedData = function (treeData, targetId) {

                            for (var k = 0; k < treeData.length; k++) {
                                var nodeId = treeData[k].id;
                                if (targetId == nodeId) {
                                    treeData[k].selected = true;
                                    return;
                                } else {
                                    if (treeData[k].children && treeData[k].children != '') {
                                        selectedData(treeData[k].children, targetId);
                                    }
                                }
                            }
                        }

                        if (data) {
                            selectedData(arr2tree, data.productCategoryId);
                        }

                        var smlSelectInstans = xmSelect.render({
                            el: '#productCategoryId',
                            model: {label: {type: 'text'}},
                            radio: true,
                            clickClose: true,
                            filterable: true,
                            tree: {
                                show: true,
                                strict: false,
                                expandedKeys: [-1],
                            },
                            tips: '请选择物料分类',
                            prop: {
                                name: 'name',
                                value: 'id',
                                children: 'children'
                            },
                            data() {
                                //填充数据
                                return arr2tree;
                            },
                            on(data) {
                                let parentId = data.arr.length > 0 ? data.change[0].id : -1;
                                $("input[name='productCategoryId']").val(parentId);
                            }
                        });

                        //上传附件
                        uploadImg("btnUploadExt", "btnUploadExt_path", "btnUploadExt_file");
                        if (data && data.enclosure) {
                            $('#btnUploadExt_path').html('<img src="' + data.enclosure + '" style="height: 35px;margin-right: 100px;" />');
                            layer.photos({
                                photos: '.uploadImgStyle'
                                , anim: 5
                            });
                        }

                        form.val('addCustomerProductFrom', data);
                        // 表单提交事件
                        form.on('submit(addCustomerProductSubmit)', function (d) {
                            layer.load(2);
                            let skuData = [], extProductData = [], listDataObj = {};
                            let skuObj = {};
                            let extProduct = {};
                            let row = $("[lay-id=specValue] table tbody tr");
                            let skuString = '', skuSpecValueString = '', skuSpecString = '';
                            for (let i = 0; i < row.length; i++) {
                                for (let j = 0; j < row.eq(i).find(".skuSpecValueNames").find('select').length; j++) {
                                    if (row.eq(i).find(".skuSpecValueNames").find('input').eq(j).val() == '') {
                                        skuString = '';
                                        skuSpecValueString = '';
                                        skuSpecString = '';
                                    } else {
                                        skuString += row.eq(i).find(".skuSpecValueNames").find('input').eq(j).val() + '-';
                                        skuSpecValueString += row.eq(i).find(".skuSpecValueNames").find('option:selected').eq(j).val() + '_';
                                        skuSpecString += row.eq(i).find(".skuSpecValueNames").find('option:selected').eq(j).attr('skuspec') + '_';
                                    }
                                }
                            }
                            let skuSpecValueNames = skuString.substring(0, skuString.length - 1);
                            let skuSpecValue = skuSpecValueString.substring(0, skuSpecValueString.length - 1);
                            let skuSpec = skuSpecString.substring(0, skuSpecString.length - 1);
                            //alert("skuSpecValueNames:"+skuSpecValueNames+"   skuSpecValue"+skuSpecValue);
                            //取值
                            var contactId = $("#contactId").val();
                            var extProductName = addCustomerProductForm.extProductName.value;
                            var extProductCode = addCustomerProductForm.extProductCode.value;
                            var extSpecCode = addCustomerProductForm.extSpecCode.value;
                            var enclosure = addCustomerProductForm.enclosure.value;
                            var packing = $("#packing").val();//获取是否包装当前选择项值
                            if (packing == 1 || !packing) {
                                packing = false;
                            } else {
                                packing = true;
                            }

                            var packingRequire = addCustomerProductForm.packingRequire.value;
                            var productTypeId = $("#productTypeId").val();
                            var productCategoryId = addCustomerProductForm.productCategoryId.value;
                            var productRange = $("#productRange").val();
                            /* var rangeCode = addCustomerProductForm.rangeCode.value;
                             var unitId = document.getElementById("unitId").value;*/
                            var remark = addCustomerProductForm.remark.value;
                            var skuCode = addCustomerProductForm.skuCode.value;
                            var skuName = addCustomerProductForm.skuName.value;
                            var packUnitId = $("#packUnitId").val();
                            var productPack = $("#productPack").val();
                            var weight = addCustomerProductForm.weight.value;

                            /*var options=$("# option:selected");//获取当前选择项.
                            options.val();//获取当前选择项的值.*/

                            //赋值
                            skuObj = {
                                skuCode: skuCode,
                                skuName: skuName,
                                oldSpecCode: extSpecCode,
                                unitId: packUnitId,
                                packId: productPack,
                                skuSpecValueNames: skuSpecValueNames,
                                skuSpecValue: skuSpecValue,
                                skuSpec: skuSpec,
                                productTypeId: productTypeId,
                                productCategoryId: productCategoryId,
                                productId: productRange,
                                remark: remark,
                                weightNumber: weight
                            };

                            extProduct = {
                                name: extProductName,
                                code: extProductCode,
                                spec: extSpecCode,
                                hasPack: packing,
                                packInstructions: packingRequire
                            }

                            skuData.push(skuObj);
                            extProductData.push(extProduct);
                            console.log("skuData: " + skuData);
                            console.log("extProductData: " + extProductData);

                            listDataObj.productDetailForm = skuData;
                            listDataObj.externalProductForm = extProductData;
                            listDataObj.customerId = c_data.id;
                            listDataObj.contactId = contactId;
                            listDataObj.skuCode = skuCode;
                            listDataObj.enclosure = enclosure;
                            listDataObj.extProductCode = extProductCode;
                            console.log("listDataObj: " + listDataObj);

                            admin.req('enterprise/sell/admin/customerProductCatalog/addProduct', JSON.stringify(listDataObj), function (res) {
                                layer.closeAll('loading');
                                if (res.code === 200) {
                                    layer.closeAll();
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('customerProductCatalogTable');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'POST', true, 'application/json; charset=utf-8');
                        });

                    }
                })
            }
        }

        //跟进记录
        function followRecordInfo(data) {
            // 渲染表格
            var insTb = table.render({
                elem: '#customerFollowRecordTable,#customerFollowRecordTable2',
                url: config.base + 'enterprise/sell/admin/customerFollowRecord/list',
                where: {customerType: 3, followCustomer: data.id},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'customerTypeDesc', align: 'center', title: '客户类型'}
                    , {field: 'followTypeName', align: 'center', title: '跟进类型'}
                    , {field: 'followCustomerName', align: 'center', title: '跟进客户'}
                    , {field: 'followTargetName', align: 'center', title: '跟进对象'}
                    , {field: 'followWayName', align: 'center', title: '跟进方式'}
                    , {field: 'followResultName', align: 'center', title: '跟进结果'}
                    , {field: 'cost', align: 'center', title: '产生费用'}
                    , {field: 'followDescribe', align: 'center', title: '结果描述'}
                    , {field: 'approverName', align: 'center', title: '审批人'}
                    , {field: 'statusDesc', align: 'center', title: '状态'}
                    , {field: 'createTime', align: 'center', title: '创建时间', width: 160}
                    , {align: 'center', toolbar: '#customerFollowRecordTableBar', title: '操作', width: 150}
                ]],

            });

            // 工具条点击事件
            table.on('tool(customerFollowRecordTable)', function (obj) {
                var data = obj.data;
                var type = 0;//0-详情，1-审核
                if (obj.event === 'edit') { //修改
                    showEditModel(data);
                } else if (obj.event === 'del') { // 删除
                    doDelete(obj);
                } else if (obj.event === 'detail') {//详情
                    showDetail(data, type);
                } else if (obj.event === 'process') {//审核
                    type = 1;
                    showDetail(data, type);
                }
            });

            // 搜索
            //获取客户数据
            admin.req('enterprise/sell/admin/customersInfo/getCustomerByType', {}, function (res) {
                if (res.code == 200) {
                    loadSelectHtml(res.data, "请选择跟进客户", "followCustomer", "customerName");
                } else {
                    layer.msg('获取客户失败', {icon: 2, time: 1000});
                }
            }, 'GET');

            form.on('submit(formSubSearchLog)', function (data) {
                insTb.reload({where: data.field, page: {curr: 1}}, 'data');
            });

            // 添加按钮点击事件
            $('#customerFollowRecordBtnAdd,#customerFollowRecordBtnAdd2').click(function () {
                showEditModel(null, true);
            });

            //详情弹窗
            function showDetail(data, type) {
                admin.open({
                    type: 1,
                    area: '760px',
                    offset: '115px',
                    title: type === 1 ? '审核跟进记录' : '跟进记录详情',
                    content: $('#customerFollowRecordDetailForm').html(),
                    success: function () {
                        if (data) {
                            var option = $("form select[name='customerType']").find("option");
                            layui.each(option, function (index, item) {
                                if (data.customerType == item.text) {
                                    data.customerType = item.value;
                                }
                            });
                        }

                        form.val('customerFollowRecordDetailForm', data);

                        getCompany(data);// 获取客户数据

                        getContactInfo(data);// 获取客户联系人

                        getFollowType(data);// 获取跟进类型

                        getFollowWay(data);// 获取跟进方式

                        getFollowResultType(data);// 获取跟进结果类型

                        getUsers(data);// 获取审批人

                        $(".selectDisabled").attr("disabled", "disabled");
                        //$(".selectDisabled").attr("style", "background-color: #EEEEEE;");//设为灰色
                        //$(".selectDisabled").attr("style", "border: none;");

                        if (type == 0) {
                            $('#followRemark').attr("disabled", true);
                            $('#customerFollowRecordDetailFormSubmit').hide();//提交按钮隐藏
                        } else if (type == 1) {
                            $('#followRemark').attr("disabled", false);
                            $('#customerFollowRecordDetailFormSubmit').show();//提交按钮显示

                            form.on('submit(customerFollowRecordDetailFormSubmit)', function (d) {
                                admin.req('enterprise/sell/admin/customerFollowRecord/audit', d.field, function (res) {
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {icon: 1});
                                        table.reload('customerFollowRecordTable');
                                        layer.closeAll('page');
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'PUT')
                            });
                        }

                    }
                });
            }

            // 显示跟进记录编辑弹窗
            function showEditModel(data, istrue) {
                admin.open({
                    type: 1,
                    area: '760px',
                    offset: '110px',
                    title: data ? '修改跟进记录管理' : '添加跟进记录管理',
                    content: $('#customerFollowRecordForm').html(),
                    success: function () {
                        if (data) {
                            var option = $("form select[name='customerType']").find("option");
                            layui.each(option, function (index, item) {
                                if (data.customerType == item.text) {
                                    data.customerType = item.value;
                                }
                            });
                        }
                        if (istrue) {
                            let val = ''
                            let utl = window.location.href
                            if (utl.indexOf('customersInfo') > -1) {
                                val = 'formal'
                            } else if (utl.indexOf('intendedCustomersInfo') > -1) {
                                val = 'Intended'
                            } else if (utl.indexOf('potentialCustomersInfo') > -1) {
                                val = 'potential'
                            }
                            $('#followCustomerType').val(val);
                            var followCoustomer = {};
                            followCoustomer.value = val;
                            getCompany(followCoustomer); // 获取客户数据
                        }

                        form.val('customerFollowRecordForm', data);

                        form.on('select(customerType)', function (data) {
                            getCompany(data); // 获取客户数据
                        });
                        form.on('select(followCustomer)', function (data) {
                            getContactInfo(data);// 获取客户联系人
                        })

                        getFollowType(data);// 获取跟进类型

                        getFollowWay(data);// 获取跟进方式

                        getFollowResultType(data);// 获取跟进结果类型

                        getUsers(data);// 获取审批人
                        form.on('select(approver)', function (data) {//审批人姓名
                            admin.req('user/admin/user/getUserInfoByUserId', {userId: data.value}, (res) => {
                                if (res.code == '200') {
                                    $("#followApproverName").val(res.data.nickname);
                                }
                            }, 'GET');
                        });

                        // 表单提交事件
                        form.on('submit(customerFollowRecordFormSubmit)', function (d) {
                            layer.load(2);
                            admin.req(data ? 'enterprise/sell/admin/customerFollowRecord/update' : 'enterprise/sell/admin/customerFollowRecord/add', d.field, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('customerFollowRecordTable');
                                    layer.closeAll('page');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, data ? 'PUT' : 'POST');
                            return false;
                        });
                    }
                });
            }

        }

        //客户线索信息
        function customerLeadsInfo(data) {
            //展示客户线索信息
            admin.req('enterprise/sell/admin/customersInfo/getLeadList', {id: data.id}, (res) => {
                if (res.code == '200' && res.data.length > 0) {
                    form.val('customerLeadsForm', res.data[0]);

                    //客户录入人电话
                    admin.req('user/admin/user/getUserInfoByUserId', {userId: res.data[0].agtCreator}, (res2) => {
                        if (res2.code == '200') {
                            $("#agtCreatorPhone").val(res2.data.phone);
                        }
                    }, 'GET');

                    //服务专员电话
                    admin.req('user/admin/user/getUserInfoByUserId', {userId: res.data[0].salesmanId}, (salesmanRes) => {
                        if (salesmanRes.code == '200') {
                            $("#salesmanPhone").val(salesmanRes.data.phone);
                        }
                    }, 'GET');
                }
            }, 'GET');

            //下拉框-获取所属服务专员
            getUsers(data);
            form.on('select(salesmanId)', function (data) {
                admin.req('user/admin/user/getUserInfoByUserId', {userId: data.value}, (res) => {
                    if (res.code == '200') {
                        $("#salesmanPhone").val(res.data.phone);
                    }
                }, 'GET');
            });

            //修改服务专员
            $("#customersLeadsUpdate").click(function () {
                var salesmanId = $("#salesmanId").val();

                admin.req('enterprise/sell/admin/customersInfo/updateSalesman', {
                    id: data.id,
                    salesmanId: salesmanId
                }, function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        table.reload('detailTable');
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'PUT')

            });
        }

        //合同管理
        function customerContract(data) {
            var subjectId = data.id;
            // 获取合同分类
            admin.req('enterprise/contract/admin/contractCategory/getTreeData', {type: "client"}, function (res) {
                if (200 == res.code) {
                    xmSelect.render({
                        el: '#selContractCategory',
                        model: {label: {type: 'text'}},
                        radio: true,
                        clickClose: true,
                        filterable: true,
                        tree: {
                            show: true,
                            strict: false,
                            /*expandedKeys: [-1],*/
                            expandedKeys: true,
                        },
                        tips: '请选择合同分类',
                        height: 'auto',
                        data() {
                            return res.data;
                        },
                        on: function (data) {
                            //被选中的select的id,如果没有 -1
                            let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                            $("input[name='contractCategoryId']").val(contractCategoryId);
                        },
                    });
                } else {
                    layer.msg('获取合同分类失败!', {icon: 2, time: 1000});
                }
            }, 'GET');

            //时间范围
            laydate.render({
                elem: '#pTime',
                type: 'datetime',
                range: true,
                done: function (value, date, endDate) {
                    var dateValue = value.split(" - ");
                    $("#sTime").val(dateValue[0]);
                    $("#eTime").val(dateValue[1]);
                }
            });

            // 渲染表格
            var insTb = table.render({
                elem: '#contractTable',
                url: config.base + 'enterprise/sell/admin/customerContract/list',
                where: {subjectId: subjectId},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}
                    , {field: 'code', align: 'center', title: '合同编号', width: 180}
                    , {field: 'typeDesc', align: 'center', title: '合同主体类型'}
                    , {align: 'center', title: '关联订单数'}
                    , {field: 'companyName', align: 'center', title: '客户名称'}
                    , {field: 'contractCategoryName', align: 'center', title: '合同分类'}
                    , {field: 'createTime', align: 'center', title: '创建时间'}
                    , {field: 'contactName', align: 'center', title: '客户签约人'}
                    , {field: 'amount', align: 'center', title: '签约金额'}
                    , {
                        field: 'attachment',
                        align: 'center',
                        title: '合同附件',
                        toolbar: '#viewAttachmentBar'
                    }
                    , {field: 'statusDesc', align: 'center', title: '合同状态'}
                    , {align: 'center', toolbar: '#contractTableBar', title: '操作', width: 210}
                ]],
                done: function (res, curr, count) {
                    //移除按钮
                    var menuButton = config.getMenuButton(location.hash);
                    if (menuButton.indexOf("搜索") == -1) {
                        $('.layui-form.toolbar').remove();
                    }
                    if (menuButton.indexOf("修改") == -1) {
                        $("[lay-event='edit']").remove();
                    }
                    if (menuButton.indexOf("删除") == -1) {
                        $("[lay-event='del']").remove();
                    }
                }
            });

            // 工具条点击事件
            table.on('tool(contractTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') { //修改
                    showEditModel(data);
                } else if (obj.event === 'del') { // 删除
                    doDelete(obj);
                } else if (obj.event === 'view') { // 详情
                    showViewModel(data);
                } else if (obj.event === 'changeRecord') { // 变更记录
                    showChangeRecordModel(data);
                } else if (obj.event === 'relatedProduct') { // 物料
                    showRelatedProductModel(data);
                } else if (obj.event === 'viewAttachment') { // 查看附件
                    showViewAttachmentModel(data);
                }
            });

            //监听排序
            table.on('sort(contractTable)', function (obj) {
                table.reload('contractTable', {
                    initSort: obj
                    , where: {
                        sort: obj.field
                        , order: obj.type
                    }
                });
            });

            // 搜索
            form.on('submit(formSubSearchLog)', function (data) {
                insTb.reload({where: data.field, page: {curr: 1}}, 'data');
            });

            // 重置搜索
            form.on('submit(resets)', function (data) {
                $(".lay-header").find('select').val("");
                $(".lay-header").find('input').val("");
                let field = data.field;
                for (let key in field) {
                    field[key] = ''
                }
                insTb.reload({where: field, page: {curr: 1}}, 'data');
            });

            // 添加按钮点击事件
            $('#contractBtnAdd').click(function () {
                showEditModel();
            });

            // 显示编辑弹窗
            function showEditModel(data) {
                var contractTable = admin.open({
                    type: 1,
                    area: '800px',
                    title: data ? '修改合同' : '添加合同',
                    content: $('#contractForm').html(),
                    success: function () {
                        //自定义验证规则
                        form.verify({
                            decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                            contractCategoryId: function (value) {
                                if (value == "") {
                                    return "请选择合同分类";
                                }
                            },
                            attachment: function (value) {
                                if (value == "") {
                                    return "请上传附件";
                                }
                            }
                        })

                        // 获取合同主体类型
                        admin.req('enterprise/contract/admin/contractCategory/types', {}, function (res) {
                            if (200 == res.code) {
                                $.each(res.data, function (index, item) {
                                    $("form select[name='type']").append(new Option(item.name, item.id));//往下拉菜单里添加元素
                                })
                                $("form select[name='type']").find("option").each(function (index, item) {
                                    // 默认主体类型为客户
                                    if ($(item).val() == "client") {
                                        $(item).attr("selected", true);
                                    }
                                })
                                form.render(); //菜单渲染 把内容加载进去
                            } else {
                                layer.msg('获取合同主体类型失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        var selectId = null;
                        if (data && data.contractCategoryId) {
                            selectId = data.contractCategoryId;
                        }
                        // 获取合同分类
                        admin.req('enterprise/contract/admin/contractCategory/getTreeData', {
                            selectId: selectId,
                            type: "client"
                        }, function (res) {
                            if (200 == res.code) {
                                xmSelect.render({
                                    el: '#selectContractCategory',
                                    model: {label: {type: 'text'}},
                                    radio: true,
                                    clickClose: true,
                                    filterable: true,
                                    tree: {
                                        show: true,
                                        strict: false,
                                        /*expandedKeys: [-1],*/
                                        expandedKeys: true,
                                    },
                                    tips: '请选择合同分类',
                                    height: 'auto',
                                    data() {
                                        return res.data;
                                    },
                                    on: function (data) {
                                        //被选中的select的id,如果没有 -1
                                        let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                                        $("input[name='contractCategoryId']").val(contractCategoryId);
                                    },
                                });
                            } else {
                                layer.msg('获取合同分类失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 获取签约主体
                        admin.req('enterprise/sell/admin/customersInfo/getBasicInfo', {customerType: "2,3"}, function (res) {
                            console.log(res.data);
                            if (200 == res.code) {

                                $("form select[name='subjectId']").append(new Option("请选择签约主体", ""));//往下拉菜单里添加元素
                                $.each(res.data, function (index, item) {
                                    $("form select[name='subjectId']").append(new Option(item.customerName, item.id));//往下拉菜单里添加元素
                                })
                                $("form select[name='subjectId']").val(subjectId);
                                form.render(); //菜单渲染 把内容加载进去
                            } else {
                                layer.msg('获取签约主体失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 获取客户签约人
                        admin.req('enterprise/sell/admin/contactInfo/list', {
                            limit: 99999,
                            selCustomerId: subjectId
                        }, function (res) {
                            if (200 == res.code) {
                                $("form select[name='contactsId']").html("");
                                $("form select[name='contactsId']").append(new Option("请选择客户签约人", ""));//往下拉菜单里添加元素
                                $.each(res.data, function (index, item) {
                                    $("form select[name='contactsId']").append(new Option(item.name + "(" + item.telephone + ")", item.id));//往下拉菜单里添加元素
                                })
                                form.render(); //菜单渲染 把内容加载进去
                                if (data && data.contactsId) {
                                    form.val('contractForm', data);
                                }
                            } else {
                                layer.msg('获取客户签约人失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 获取我方签约人
                        admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                            console.log(res.data);
                            if (200 == res.code) {
                                $("form select[name='contractor']").append(new Option("请选择我方签约人", ""));//往下拉菜单里添加元素
                                $.each(res.data, function (index, item) {
                                    $("form select[name='contractor']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                })
                                form.render(); //菜单渲染 把内容加载进去
                                if (data && data.contractor) {
                                    form.val('contractForm', data);
                                }
                            } else {
                                layer.msg('获取我方签约人失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 获取信息审批人
                        admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                            console.log(res.data);
                            if (200 == res.code) {
                                $("form select[name='approver']").append(new Option("请选择信息审批人", ""));//往下拉菜单里添加元素
                                $.each(res.data, function (index, item) {
                                    $("form select[name='approver']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                })
                                form.render(); //菜单渲染 把内容加载进去
                                if (data && data.approver) {
                                    form.val('contractForm', data);
                                }
                            } else {
                                layer.msg('获取信息审批人失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 上传附件
                        upload.render({
                            elem: '#addDevicePicBtn'
                            , url: config.upload_url + 'uploadFile'
                            , data: {}
                            , accept: 'file'
                            , exts: 'pdf'
                            , headers: {Authorization: 'Bearer ' + config.getToken()}
                            , done: function (res) {
                                if (res.code == 200) {
                                    layer.msg(res.msg || "上传成功", {icon: 1});
                                    let imagUrl = res.data.url;
                                    var name = res.data.fileName;
                                    $('#addHeaderImg').html('<div class="attachments">' +
                                        '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">' + name + '</span></div></div>');
                                    $('#attachment').val(imagUrl);

                                    $(".attachments").click(function () {
                                        var json = {};
                                        json.attachment = imagUrl;
                                        showViewAttachmentModel(json);
                                    })
                                } else if (res.code == 502) {
                                    return location.replace('admin/login.html');
                                } else {
                                    layer.msg(res.msg || "上传失败", {icon: 2});
                                }
                            }
                        });

                        form.val('contractForm', data);
                        // 表单提交事件
                        form.on('submit(contractFormSubmit)', function (d) {
                            layer.load(2);
                            admin.req(data ? 'enterprise/sell/admin/customerContract/update' : 'enterprise/sell/admin/customerContract/add', d.field, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('contractTable');
                                    layer.close(contractTable);
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, data ? 'PUT' : 'POST');
                            return false;
                        });
                    }
                });
            }

            // 删除
            function doDelete(obj) {
                layer.confirm('确定要删除吗？', {
                    offset: '65px',
                    skin: 'layui-layer-admin'
                }, function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('enterprise/sell/admin/customerContract/' + obj.data.id, {}, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            obj.del();
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'DELETE');
                });
            }

            // 显示详情弹窗
            function showViewModel(data) {
                admin.open({
                    type: 1,
                    area: ['80%', '80%'],
                    title: '合同详情',
                    content: $('#contractView').html(),
                    success: function () {
                        // 查询我方签约人
                        admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                            console.log(res.data);
                            if (200 == res.code) {
                                $.each(res.data, function (index, item) {
                                    if (item.id == data.contractor) {
                                        $("#contractorName").text("我方签约人：" + item.nickname + "(" + item.username + ")");
                                    }
                                })
                            } else {
                                layer.msg('获取我方签约人失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 查询合同保管员
                        admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                            if (200 == res.code) {
                                $.each(res.data, function (index, item) {
                                    if (item.id == data.keeper) {
                                        $("#keeperName").text("合同保管员：" + item.nickname + "(" + item.username + ")");
                                    }
                                })
                            } else {
                                layer.msg('获取合同保管员失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        // 查询信息审批人
                        admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                            if (200 == res.code) {
                                $.each(res.data, function (index, item) {
                                    if (item.id == data.approver) {
                                        $("#approverName").text("信息审批人：" + item.nickname + "(" + item.username + ")");
                                    }
                                })
                            } else {
                                layer.msg('获取信息审批人失败!', {icon: 2, time: 1000});
                            }
                        }, 'GET');

                        $("#attachmentName").text("合同附件：" + data.attachment.substring(data.attachment.lastIndexOf("/") + 1));

                        laytpl(contractInfoHtml.innerHTML).render(data, function (html) {
                            $("#contractInfo").html(html);
                        });

                        if (data.attachment) {
                            PDFObject.embed(data.attachment, "#example1");
                        }
                    }
                })
            }

            // 变更记录
            function showChangeRecordModel(data) {
                var supplierContract = data;
                admin.open({
                    type: 1,
                    area: ['80%', '80%'],
                    title: '合同变更记录',
                    content: $('#contractChangeRecord').html(),
                    success: function () {
                        isShowAddBtn(supplierContract);

                        // 渲染表格
                        var changeRecordInsTb = table.render({
                            elem: '#contractChangeRecordTable',
                            url: config.base + 'enterprise/sell/admin/customerContract/contractChangeRecordList',
                            where: {contractId: supplierContract.id},
                            page: true,
                            cellMinWidth: 100,
                            cols: [[
                                {type: 'numbers'}
                                , {field: 'code', align: 'center', title: '合同编号', width: 150}
                                , {field: 'typeDesc', align: 'center', title: '合同主体类型', width: 120}
                                , {field: 'companyName', align: 'center', title: '客户名称', width: 140}
                                , {field: 'contractCategoryName', align: 'center', title: '合同分类', width: 120}
                                , {field: 'createTime', align: 'center', title: '创建时间', width: 160}
                                , {field: 'contactName', align: 'center', title: '客户签约人', width: 120}
                                , {field: 'amount', align: 'center', title: '签约金额', width: 110}
                                , {
                                    field: 'attachment',
                                    align: 'center',
                                    title: '合同附件',
                                    width: 110,
                                    toolbar: '#viewAttachmentBar'
                                }
                                , {field: 'statusDesc', align: 'center', title: '合同状态', width: 110}
                                , {align: 'center', toolbar: '#contractChangeRecordTableBar', title: '操作', width: 180}
                            ]],
                            done: function (res, curr, count) {

                            }
                        });

                        // 工具条点击事件
                        table.on('tool(contractChangeRecordTable)', function (obj) {
                            var data = obj.data;
                            if (obj.event === 'edit') { // 修改
                                showEditModel(data);
                            } else if (obj.event === 'view') { // 详情
                                showViewModel(data);
                            } else if (obj.event === 'audit') { // 审核
                                showAuditModel(data);
                            } else if (obj.event === 'final') { // 终版
                                doFinal(data);
                            } else if (obj.event === 'viewAttachment') { // 查看附件
                                showViewAttachmentModel(data);
                            }
                        });

                        // 搜索
                        form.on('submit(contractChangeRecordFormSubSearchLog)', function (data) {
                            changeRecordInsTb.reload({where: data.field, page: {curr: 1}}, 'data');
                        });

                        // 重置搜索
                        form.on('submit(contractChangeRecordResets)', function (data) {
                            $("#changeRecord").find(".lay-header").find('select').val("");
                            $("#changeRecord").find(".lay-header").find('input').val("");
                            let field = data.field;
                            for (let key in field) {
                                field[key] = ''
                            }
                            changeRecordInsTb.reload({where: field, page: {curr: 1}}, 'data');
                        });

                        // 添加按钮点击事件
                        $('#contractChangeRecordBtnAdd').click(function () {
                            showEditModel();
                        });

                        // 显示编辑弹窗
                        function showEditModel(data) {
                            var contractChangeRecord = admin.open({
                                type: 1,
                                area: ['800px', '70%'],
                                title: data ? '修改合同变更记录' : '添加合同变更记录',
                                content: $('#contractChangeRecordForm').html(),
                                success: function () {
                                    //自定义验证规则
                                    form.verify({
                                        decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                                        contractCategoryId: function (value) {
                                            if (value == "") {
                                                return "请选择合同分类";
                                            }
                                        },
                                        attachment: function (value) {
                                            if (value == "") {
                                                return "请上传附件";
                                            }
                                        }
                                    })

                                    // 签约时间
                                    laydate.render({
                                        elem: '#signingTime',
                                        type: 'date'
                                    });

                                    // 交货时间
                                    laydate.render({
                                        elem: '#deliveryTime',
                                        type: 'date'
                                    });

                                    var selectId = null;
                                    if (supplierContract && supplierContract.contractCategoryId) {
                                        selectId = supplierContract.contractCategoryId;
                                    }
                                    if (data && data.contractCategoryId) {
                                        selectId = data.contractCategoryId;
                                    }
                                    // 获取合同分类
                                    admin.req('enterprise/contract/admin/contractCategory/getTreeData', {
                                        selectId: selectId,
                                        type: "client"
                                    }, function (res) {
                                        if (200 == res.code) {
                                            xmSelect.render({
                                                el: '#selectContractCategory',
                                                model: {label: {type: 'text'}},
                                                radio: true,
                                                clickClose: true,
                                                filterable: true,
                                                tree: {
                                                    show: true,
                                                    strict: false,
                                                    /*expandedKeys: [-1],*/
                                                    expandedKeys: true,
                                                },
                                                tips: '请选择合同分类',
                                                height: 'auto',
                                                data() {
                                                    return res.data;
                                                },
                                                on: function (data) {
                                                    //被选中的select的id,如果没有 -1
                                                    let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                                                    $("input[name='contractCategoryId']").val(contractCategoryId);
                                                },
                                            });
                                        } else {
                                            layer.msg('获取合同分类失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    var selCustomerId = null;
                                    if (supplierContract && supplierContract.subjectId) {
                                        selCustomerId = supplierContract.subjectId;
                                    }
                                    if (data && data.subjectId) {
                                        selCustomerId = data.subjectId;
                                    }
                                    if (selCustomerId) {
                                        // 获取客户签约人
                                        admin.req('enterprise/sell/admin/contactInfo/list', {
                                            limit: 99999,
                                            selCustomerId: selCustomerId
                                        }, function (res) {
                                            if (200 == res.code) {
                                                $("form select[name='contactsId']").html("");
                                                $("form select[name='contactsId']").append(new Option("请选择客户签约人", ""));//往下拉菜单里添加元素
                                                $.each(res.data, function (index, item) {
                                                    $("form select[name='contactsId']").append(new Option(item.name + "(" + item.telephone + ")", item.id));//往下拉菜单里添加元素
                                                })
                                                form.render(); //菜单渲染 把内容加载进去
                                                if (data && data.contactsId) {
                                                    form.val('contractChangeRecordForm', data);
                                                } else {
                                                    form.val('contractChangeRecordForm', supplierContract);
                                                }
                                            } else {
                                                layer.msg('获取客户签约人失败!', {icon: 2, time: 1000});
                                            }
                                        }, 'GET');
                                    }


                                    // 获取我方签约人
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $("form select[name='contractor']").append(new Option("请选择我方签约人", ""));//往下拉菜单里添加元素
                                            $.each(res.data, function (index, item) {
                                                $("form select[name='contractor']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                            })
                                            form.render(); //菜单渲染 把内容加载进去
                                            if (data && data.contractor) {
                                                form.val('contractChangeRecordForm', data);
                                            } else {
                                                form.val('contractChangeRecordForm', supplierContract);
                                            }
                                        } else {
                                            layer.msg('获取我方签约人失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    // 获取信息审批人
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $("form select[name='approver']").append(new Option("请选择信息审批人", ""));//往下拉菜单里添加元素
                                            $.each(res.data, function (index, item) {
                                                $("form select[name='approver']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                            })
                                            form.render(); //菜单渲染 把内容加载进去
                                            if (data && data.approver) {
                                                form.val('contractChangeRecordForm', data);
                                            } else {
                                                form.val('contractChangeRecordForm', supplierContract);
                                            }
                                        } else {
                                            layer.msg('获取信息审批人失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    // 上传附件
                                    upload.render({
                                        elem: '#addDevicePicBtn'
                                        , url: config.upload_url + 'uploadFile'
                                        , data: {}
                                        , accept: 'file'
                                        , exts: 'pdf'
                                        , headers: {Authorization: 'Bearer ' + config.getToken()}
                                        , done: function (res) {
                                            if (res.code == 200) {
                                                layer.msg(res.msg || "上传成功", {icon: 1});
                                                let imagUrl = res.data.url;
                                                var name = res.data.fileName;
                                                $('#addHeaderImg').html('<div class="attachments">' +
                                                    '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">' + name + '</span></div></div>');
                                                $('#attachment').val(imagUrl);

                                                $(".attachments").click(function () {
                                                    var json = {};
                                                    json.attachment = imagUrl;
                                                    showViewAttachmentModel(json);
                                                })
                                            } else if (res.code == 502) {
                                                return location.replace('admin/login.html');
                                            } else {
                                                layer.msg(res.msg || "上传失败", {icon: 2});
                                            }
                                        }
                                    });

                                    var attachment = "";
                                    if (supplierContract && supplierContract.attachment) {
                                        attachment = supplierContract.attachment;
                                    }
                                    if (data && data.attachment) {
                                        attachment = data.attachment;
                                    }

                                    if (attachment != "") {
                                        var name = attachment.substring(attachment.lastIndexOf("/") + 1);
                                        // onclick="previewFile(\''+name+'\', \''+attachment+'\')"
                                        $('#addHeaderImg').html('<div class="attachments">' +
                                            '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">' + name + '</span></div></div>');
                                        $('#attachment').val(attachment);

                                        $(".attachments").click(function () {
                                            var json = {};
                                            json.attachment = attachment;
                                            showViewAttachmentModel(json);
                                        })
                                    }

                                    // 获取合同保管员
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $("form select[name='keeper']").append(new Option("请选择合同保管员", ""));//往下拉菜单里添加元素
                                            $.each(res.data, function (index, item) {
                                                $("form select[name='keeper']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                            })
                                            form.render(); //菜单渲染 把内容加载进去
                                            if (data && data.keeper) {
                                                form.val('contractChangeRecordForm', data);
                                            }
                                        } else {
                                            layer.msg('获取合同保管员失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    form.on('switch(isFinal)', function (obj) {
                                        if (obj.elem.checked) {
                                            $("#content").show();
                                            $("#deliveryTime").attr("lay-verify", "required").attr("required");
                                            $("input[name='address']").attr("lay-verify", "required").attr("required", true);
                                            $("select[name='keeper']").attr("lay-verify", "required").attr("required", true).attr("lay-search", true);
                                            form.render();
                                        } else {
                                            $("#content").hide();
                                            $("#deliveryTime").removeAttr("lay-verify");
                                            $("input[name='address']").removeAttr("lay-verify");
                                            $("select[name='keeper']").removeAttr("lay-verify");
                                        }
                                    })

                                    if (data) {
                                        form.val('contractChangeRecordForm', data);
                                    } else {
                                        form.val('contractChangeRecordForm', supplierContract);
                                    }
                                    // 表单提交事件
                                    form.on('submit(contractChangeRecordFormSubmit)', function (d) {
                                        layer.load(2);
                                        var isFinal = $("form input[name='isFinal']").prop("checked");
                                        if (!isFinal) {
                                            d.field.isFinal = false;
                                        } else {
                                            d.field.isFinal = true;
                                        }
                                        if (d.field.signingTime) {
                                            d.field.signingTime = d.field.signingTime + " 00:00:00";
                                        }
                                        if (d.field.deliveryTime) {
                                            d.field.deliveryTime = d.field.deliveryTime + " 00:00:00";
                                        }
                                        d.field.contractId = supplierContract.id;
                                        admin.req(data ? 'enterprise/sell/admin/customerContract/updateContractChangeRecord' : 'enterprise/sell/admin/customerContract/addContractChangeRecord', d.field, function (res) {
                                            layer.closeAll('loading');
                                            if (res.code == 200) {
                                                layer.msg(res.msg, {icon: 1});
                                                isShowAddBtn(supplierContract);
                                                table.reload('contractChangeRecordTable');
                                                layer.close(contractChangeRecord);
                                            } else {
                                                layer.msg(res.msg, {icon: 2});
                                            }
                                        }, data ? 'PUT' : 'POST');
                                        return false;
                                    });
                                }
                            });
                        }

                        // 显示审核弹窗
                        function showAuditModel(data) {
                            var contractAudit = admin.open({
                                type: 1,
                                area: ['80%', '80%'],
                                title: '合同审核',
                                content: $('#contractAuditForm').html(),
                                success: function () {
                                    // 查询我方签约人
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $.each(res.data, function (index, item) {
                                                if (item.id == data.contractor) {
                                                    $("#contractorName").text("我方签约人：" + item.nickname + "(" + item.username + ")");
                                                }
                                            })
                                        } else {
                                            layer.msg('获取我方签约人失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    // 查询合同保管员
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $.each(res.data, function (index, item) {
                                                if (item.id == data.keeper) {
                                                    $("#keeperName").text("合同保管员：" + item.nickname + "(" + item.username + ")");
                                                }
                                            })
                                        } else {
                                            layer.msg('获取合同保管员失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    // 查询信息审批人
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $.each(res.data, function (index, item) {
                                                if (item.id == data.approver) {
                                                    $("#approverName").text("信息审批人：" + item.nickname + "(" + item.username + ")");
                                                }
                                            })
                                        } else {
                                            layer.msg('获取信息审批人失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');


                                    $("#attachmentName").text("合同附件：" + data.attachment.substring(data.attachment.lastIndexOf("/") + 1));

                                    laytpl(contractInfoHtml.innerHTML).render(data, function (html) {
                                        $("#contractInfo").html(html);
                                    });

                                    if (data.attachment) {
                                        PDFObject.embed(data.attachment, "#example1");
                                    }

                                    form.val('contractAuditForm', data);

                                    // 表单提交事件
                                    form.on('submit(contractAuditFormSubmit)', function (d) {
                                        layer.load(2);
                                        d.field.status = $(this).data("status");
                                        admin.req('enterprise/sell/admin/customerContract/auditContractChangeRecord', d.field, function (res) {
                                            layer.closeAll('loading');
                                            if (res.code == 200) {
                                                layer.msg(res.msg, {icon: 1});
                                                isShowAddBtn(supplierContract);
                                                table.reload('contractChangeRecordTable');
                                                layer.close(contractAudit);
                                            } else {
                                                layer.msg(res.msg, {icon: 2});
                                            }
                                        }, 'POST');
                                        return false;
                                    });

                                }
                            })
                        }

                        // 终版
                        function doFinal(data) {
                            var contractFinal = admin.open({
                                type: 1,
                                area: ['800px'],
                                offset: '65px',
                                title: '合同终版确认',
                                content: $('#contractFinalForm').html(),
                                success: function () {
                                    // 交货时间
                                    laydate.render({
                                        elem: '#deliveryTime',
                                        type: 'date'
                                    });

                                    // 获取合同保管员
                                    admin.req('user/admin/user/list', {limit: 99999}, function (res) {
                                        if (200 == res.code) {
                                            $("form select[name='keeper']").append(new Option("请选择合同保管员", ""));//往下拉菜单里添加元素
                                            $.each(res.data, function (index, item) {
                                                $("form select[name='keeper']").append(new Option(item.nickname + "(" + item.username + ")", item.id));//往下拉菜单里添加元素
                                            })
                                            form.render(); //菜单渲染 把内容加载进去
                                        } else {
                                            layer.msg('获取合同保管员失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                    form.val('contractFinalForm', data);

                                    // 表单提交事件
                                    form.on('submit(contractFinalFormSubmit)', function (d) {
                                        layer.load(2);
                                        if (d.field.deliveryTime) {
                                            d.field.deliveryTime = d.field.deliveryTime + " 00:00:00";
                                        }
                                        admin.req('enterprise/sell/admin/customerContract/setContractFinal', d.field, function (res) {
                                            layer.closeAll('loading');
                                            if (res.code == 200) {
                                                layer.msg(res.msg, {icon: 1});
                                                isShowAddBtn(supplierContract);
                                                table.reload('contractChangeRecordTable');
                                                table.reload('contractTable');
                                                layer.close(contractFinal);
                                            } else {
                                                layer.msg(res.msg, {icon: 2});
                                            }
                                        }, 'POST');
                                        return false;
                                    });

                                }
                            })

                        }

                    }
                })
            }

            // 关联物料
            function showRelatedProductModel(data) {
                var contractData = data;
                admin.open({
                    type: 1,
                    area: ['80%', '80%'],
                    title: '合同关联物料',
                    content: $('#contractRelatedProduct').html(),
                    success: function () {
                        console.log(contractData);

                        // 渲染表格
                        table.render({
                            elem: '#contractRelatedProductContractTable',
                            // url: config.base + 'enterprise/sell/admin/customerContract/list',
                            // where: {id: data.id},
                            data: [contractData],
                            page: false,
                            cellMinWidth: 100,
                            cols: [[
                                {type: 'numbers'}
                                , {field: 'code', align: 'center', title: '合同编号', width: 150}
                                , {field: 'typeDesc', align: 'center', title: '合同主体类型', width: 140}
                                , {field: 'companyName', align: 'center', title: '客户名称', width: 140}
                                , {field: 'contractCategoryName', align: 'center', title: '合同分类', width: 120}
                                , {field: 'createTime', align: 'center', title: '创建时间', width: 160}
                                , {field: 'contactName', align: 'center', title: '客户签约人', width: 120}
                                , {field: 'amount', align: 'center', title: '签约金额'}
                                , {
                                    field: 'attachment',
                                    align: 'center',
                                    title: '合同附件',
                                    width: 110,
                                    toolbar: '#viewAttachmentBar'
                                }
                                , {field: 'statusDesc', align: 'center', title: '合同状态'}
                                , {align: 'center', title: '操作', width: 120, toolbar: '#customerPhoneBar'}
                            ]],
                            done: function (res, curr, count) {

                            }
                        });

                        // 渲染表格
                        table.render({
                            elem: '#contractRelatedProductTable',
                            // url: config.base + 'enterprise/sell/admin/customerContract/contractRelatedProductList',
                            // where: {contractId: data.id},
                            data: [],
                            page: false,
                            cellMinWidth: 100,
                            cols: [[
                                {type: 'numbers'}
                                , {field: 'code', align: 'center', title: '客户物料编码(SKU料号)', width: 190}
                                , {field: 'typeDesc', align: 'center', title: '客户物料名称', width: 140}
                                , {field: 'companyName', align: 'center', title: '客户规格名称', width: 120}
                                , {
                                    field: 'contractCategoryName',
                                    align: 'center',
                                    title: '内部物料料号(SKU编码)',
                                    width: 190
                                }
                                , {field: 'createTime', align: 'center', title: '内部物料类型', width: 150}
                                , {field: 'contactName', align: 'center', title: '内部规格码', width: 120}
                                , {
                                    field: 'attachment',
                                    align: 'center',
                                    title: '合同附件',
                                    toolbar: '#viewAttachmentBar'
                                }
                                // , {field: 'amount', align: 'center', title: '描述', width: 110}
                                , {field: 'statusDesc', align: 'center', title: '物料状态'}
                                , {align: 'center', toolbar: '#contractChangeRecordTableBar', title: '操作', width: 200}
                            ]],
                            done: function (res, curr, count) {

                            }
                        });

                        // 工具条点击事件
                        table.on('tool(contractRelatedProductContractTable)', function (obj) {
                            var data = obj.data;
                            if (obj.event === 'viewAttachment') { // 查看附件
                                showViewAttachmentModel(data);
                            } else if (obj.event === 'viewCustomerPhone') { // 查看客户手机号
                                viewCustomerPhone(data);
                            }
                        });

                        // 添加合同物料信息
                        $("#addContractProductInfo").click(function () {
                            showEditModel();
                        })

                        // 查看客户手机号
                        function viewCustomerPhone(data) {
                            admin.open({
                                title: '客户手机号',
                                content: data.contactPhone
                            }, {
                                offset: '65px',
                                skin: 'layui-layer-admin'
                            });
                        }

                        // 显示编辑弹窗
                        function showEditModel(data) {
                            var contractRelatedProduct = admin.open({
                                type: 1,
                                area: ['70%', '70%'],
                                offset: '65px',
                                title: data ? '修改合同物料信息' : '添加合同物料信息',
                                content: $('#contractRelatedProductForm').html(),
                                success: function () {
                                    //自定义验证规则
                                    form.verify({
                                        decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                                        attachment: function (value) {
                                            if (value == "") {
                                                return "请上传附件";
                                            }
                                        }
                                    })

                                    // 查询客户信息
                                    admin.req('enterprise/sell/admin/customerContract/getCustomerInfo', {
                                        subjectId: subjectId,
                                        contactsId: contactsId
                                    }, function (res) {
                                        if (200 == res.code) {
                                            console.log(res.data);
                                            // 渲染表格
                                            table.render({
                                                elem: '#contractRelatedProductTable',
                                                // url: config.base + 'enterprise/sell/admin/customerContract/contractRelatedProductList',
                                                // where: {contractId: data.id},
                                                data: [res.data],
                                                page: false,
                                                cellMinWidth: 100,
                                                cols: [[
                                                    {type: 'numbers'}
                                                    , {field: 'code', title: '客户物料编码(SKU料号)', width: 130}
                                                    , {field: 'typeDesc', title: '客户物料名称', width: 140}
                                                    , {field: 'companyName', title: '客户规格名称', width: 120}
                                                    , {
                                                        field: 'contractCategoryName',
                                                        title: '内部物料料号（SKUID）',
                                                        width: 120
                                                    }
                                                    , {field: 'createTime', title: '内部物料类型', width: 170}
                                                    , {field: 'contactName', title: '内部规格码', width: 120}
                                                    , {
                                                        field: 'attachment',
                                                        title: '合同附件',
                                                        width: 110,
                                                        toolbar: '#viewAttachmentBar'
                                                    }
                                                    , {field: 'amount', title: '描述', width: 110}
                                                    , {field: 'statusDesc', title: '物料状态', width: 110}
                                                    , {
                                                        align: 'center',
                                                        toolbar: '#contractChangeRecordTableBar',
                                                        title: '操作',
                                                        width: 200
                                                    }
                                                ]],
                                                done: function (res, curr, count) {

                                                }
                                            });
                                        } else {
                                            layer.msg('获取客户信息失败!', {icon: 2, time: 1000});
                                        }
                                    }, 'GET');

                                }
                            });
                        }

                    }
                })
            }

            // 查看附件
            function showViewAttachmentModel(data) {
                admin.open({
                    type: 1,
                    area: ['60%', '80%'],
                    title: '查看附件',
                    content: $('#viewAttachmentHtml').html(),
                    success: function () {
                        if (data.attachment) {
                            PDFObject.embed(data.attachment, "#example1");
                        }
                    }
                })
            }

            // 是否显示添加合同变更记录按钮
            function isShowAddBtn(data) {
                admin.req('enterprise/sell/admin/customerContract/isShowAddBtn', {id: data.id}, function (res) {
                    if (200 == res.code) {
                        if (res.data) {
                            $("#opBtn").show();
                        } else {
                            $("#opBtn").hide();
                        }
                    }
                }, 'GET');
            }

        }

        //尽调
        function doDue(obj) {
            var dueFlag = true;

            table.render({
                elem: '#dueTable',
                url: config.base + 'enterprise/sell/admin/customerDue/list',
                where: {customerId: obj.data.id, customerType: obj.data.customerType},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers', title: '序号'}
                    , {field: 'code', align: 'center', title: '尽调编号'}
                    , {field: 'categoryName', align: 'center', title: '所属分类'}
                    , {field: 'subjectName', align: 'center', title: '科目名称'}
                    , {field: 'resultDesc', align: 'center', title: '尽调结果'}
                    , {field: 'statusDesc', align: 'center', title: '状态'}
                    , {field: 'createTime', align: 'center', title: '录入时间'}
                    , {field: 'auditor', align: 'center', title: '审核人'}
                    , {field: 'auditTime', align: 'center', title: '审核时间'}
                    , {align: 'center', toolbar: '#dueTableBar', title: '操作', width: 200}
                ]],
            });
            // 尽调添加按钮点击事件
            $('#dueBtnAdd').click(function () {
                dueFlag = false;
                showDueEditModel(obj);
            });


            // 显示编辑尽调弹窗
            function showDueEditModel(obj, data) {
                var index = admin.open({
                    type: 1,
                    area: ['80%', '80%'],
                    title: data ? (dueFlag ? '修改尽调记录' : '详情') : '添加尽调记录',
                    content: $('#addDueForm').html(),
                    success: function () {

                        let agentAddDueTableData = [];

                        //加载尽调分类
                        var arr2tree;
                        admin.req('enterprise/sell/admin/customerDueSubjectCategory/list', {limit: 99999}, function (res) {
                            for (let i = 0; i < res.data.length; i++) {
                                res.data[i].children = [];
                            }
                            arr2tree = xmSelect.arr2tree(res.data, "parentId", "id", "children", -1);
                        }, 'get', false);

                        var selectedData = function (treeData, targetId) {
                            for (var k = 0; k < treeData.length; k++) {
                                var nodeId = treeData[k].id;
                                if (targetId == nodeId) {
                                    treeData[k].selected = true;
                                    return;
                                } else {
                                    if (treeData[k].children && treeData[k].children != '') {
                                        selectedData(treeData[k].children, targetId);
                                    }
                                }
                            }
                        };

                        if (data) {
                            selectedData(arr2tree, data.categoryId);
                            //加载尽调科目
                            admin.reqSync('enterprise/sell/admin/customerDueSubject/list', {
                                limit: 99999,
                                subId: data.categoryId
                            }, res => {
                                if (res.code === 200) {
                                    data.subjectIdData = res.data;
                                    res.data.forEach(item => {
                                        if (item.id == data.subjectId) {
                                            data.subjectDetailData = item.paramValue.split(',')
                                        }
                                    })
                                } else {
                                    data.subjectIdData = [];
                                    data.subjectDetailData = [];
                                }
                            }, 'get', false);
                            data.categoryIdData = arr2tree;
                            data.subjectDetailArr = [];
                            data.index = 0;
                            agentAddDueTableData = [data];

                        }


                        var agentAddDueTb = table.render({
                            elem: '#addDueTable',
                            data: agentAddDueTableData,
                            toolbar: data ? '' : '#addDueFormToolbar',
                            totalRow: false,
                            defaultToolbar: [],
                            page: false,
                            limit: Number.MAX_VALUE,
                            cellMinWidth: 100,
                            cols: [[
                                {
                                    field: 'categoryId',
                                    title: '尽调分类',
                                    templet: d => '<input type="hidden" id="categoryId' + d.index + '" /> <div class="categoryIdDataBox" id="categoryIdData' + d.index + '"></div>'
                                }
                                , {
                                    field: 'subjectId', title: '尽调科目', templet: d => {
                                        let selectHTML = '<select name="subjectId" lay-filter="subjectId" lay-verify="required">';
                                        selectHTML += '<option value="">请选择</option>';
                                        d.subjectIdData.forEach((item, index) => {
                                            if (item.id === d.subjectId) {
                                                selectHTML += `<option value="${item.id}" type="${item.type}" data="${item.paramValue}" selected="">${item.name}</option>`;
                                            } else {
                                                selectHTML += `<option value="${item.id}" type="${item.type}" data="${item.paramValue}">${item.name}</option>`;
                                            }
                                        });
                                        selectHTML += '</select>';
                                        return selectHTML
                                    }
                                }
                                , {
                                    field: 'subjectDetail', title: '尽调评述', width: 300, templet: d => {
                                        let subjectDetailHtml = '<div class="subjectDetailBox">';

                                        subjectDetailHtml += '<input type="text" class="layui-input subjectType" value="' + d.subjectDetail + '" lay-verify="required">'
                                        subjectDetailHtml += '</div>';
                                        return subjectDetailHtml
                                    }
                                }
                                , {
                                    field: 'enclosure',
                                    title: '附件', width: 80, align: 'center', templet: d => {
                                        let btnHTML = '';
                                        if (!data || dueFlag) {
                                            btnHTML += `<a class="layui-btn layui-btn-xs" lay-event="uploadEnclosure">${d.enclosure ? '更改附件' : '上传附件'}</a><br/>`;
                                        }
                                        if (d.enclosure) {
                                            btnHTML += '<a class="layui-btn layui-btn-xs layui-btn-warm" href="' + d.enclosure + '" target="view_window">查看附件</a>';
                                        }

                                        return btnHTML;
                                    }
                                }
                                , {
                                    field: 'result', title: '结果', templet: d => {
                                        let selectHTML = '<select name="result" lay-filter="result" lay-verify="required">';
                                        selectHTML += `<option value="pass" ${d.result == "pass" ? "selected" : ""}>符合且可以通过</option>`;
                                        selectHTML += `<option value="check" ${d.result == "check" ? "selected" : ""}>符合在考察考察</option>`;
                                        selectHTML += `<option value="waitPass" ${d.result == "waitPass" ? "selected" : ""}>不符合但可以通过</option>`;
                                        selectHTML += `<option value="inconformity" ${d.result == "inconformity" ? "selected" : ""}>不符合</option>`;
                                        selectHTML += '</select>';
                                        return selectHTML
                                    }
                                }
                                , {
                                    field: 'detail',
                                    title: '整体评估描述',
                                    templet: d => '<input type="text" name="detail" class="layui-input" value="' + d.detail + '">'
                                },
                                data ? "" : {align: 'center', toolbar: '#addDueTableBar', title: '操作', width: 100}
                            ]],
                            done: function (res, curr, count) {
                                if (count > 0) {
                                    $('button[lay-filter="addDueFormSubmit"]').show({duration: 300})
                                } else {
                                    $('button[lay-filter="addDueFormSubmit"]').hide({duration: 300})
                                }
                                for (let i = 0; i < res.data.length; i++) {
                                    xmSelect.render({
                                        el: '#categoryIdData' + agentAddDueTableData[i].index,
                                        model: {label: {type: 'text'}},
                                        radio: true,
                                        layVerify: 'required',
                                        initValue: [agentAddDueTableData[i].categoryId],
                                        disabled: data ? (dueFlag ? false : true) : false,
                                        clickClose: true,
                                        filterable: true,
                                        tree: {
                                            show: true,
                                            strict: false,
                                            expandedKeys: [-1],
                                        },
                                        tips: '尽调分类',
                                        prop: {
                                            name: 'name',
                                            value: 'id',
                                            children: 'children'
                                        },
                                        data() {
                                            //填充数据
                                            return JSON.parse(JSON.stringify(agentAddDueTableData[i].categoryIdData));
                                        },
                                        on(data) {
                                            let parentId = data.change[0].id || '';
                                            $("#categoryId" + i).val(parentId);

                                            agentAddDueTableData[i].categoryId = parentId;
                                            agentAddDueTableData[i].subjectType = '';
                                            agentAddDueTableData[i].subjectId = '';
                                            agentAddDueTableData[i].subjectDetail = '';
                                            //加载尽调科目
                                            admin.req('enterprise/sell/admin/customerDueSubject/list', {
                                                limit: 99999,
                                                subId: parentId
                                            }, function (res) {
                                                if (res.code === 200) {
                                                    agentAddDueTableData[i].subjectIdData = res.data;
                                                } else {
                                                    agentAddDueTableData[i].subjectIdData = [];
                                                }

                                                table.reload('addDueTable', {data: agentAddDueTableData});

                                            }, 'get', false);
                                        }
                                    });

                                    upload.render({
                                        elem: $('div[lay-id="addDueTable"]').find('[lay-event="uploadEnclosure"]').eq(i)
                                        , url: config.upload_url + 'uploadFile' //上传接口
                                        , data: {}
                                        , accept: 'file'
                                        , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx|apk'
                                        , headers: {Authorization: 'Bearer ' + config.getToken()}
                                        , done: function (res) {
                                            if (res.code == 200) {
                                                layer.msg(res.msg || "上传成功", {icon: 1});
                                                let imgObj = {
                                                    fileUrl: res.data.url,
                                                    fileName: res.data.fileName
                                                };
                                                agentAddDueTableData[this.elem.parents('tr').index()].enclosure = res.data.url;
                                                table.reload('addDueTable', {data: agentAddDueTableData});
                                            } else if (res.code == 502) {
                                                return location.replace('admin/login.html');
                                            } else {
                                                layer.msg(res.msg || "上传失败", {icon: 2});
                                            }
                                        }
                                    });


                                }
                                if (!dueFlag && data) {
                                    $('div[lay-id="addDueTable"] input').attr('disabled', 'disabled');
                                    $('div[lay-id="addDueTable"] select').attr('disabled', 'disabled');
                                    $('button[lay-filter="addDueFormSubmit"]').hide({duration: 300});
                                    form.render('select');
                                }
                            }
                        });

                        //监听头工具栏事件
                        table.on('toolbar(addDueTable)', function (_obj) {
                            let data = _obj.data;
                            if (_obj.event === 'addDueFormToolbarAdd') { //添加
                                let objData = {};
                                objData.index = agentAddDueTableData.length;
                                objData.customerId = obj.data.id;
                                objData.customerType = obj.data.customerType;
                                objData.categoryIdData = arr2tree; // 尽调分类
                                objData.categoryId = ''; // 尽调分类

                                objData.subjectIdData = []; // 尽调科目
                                objData.subjectId = '';
                                objData.subjectType = '';


                                objData.subjectDetail = ''; // 尽调评述
                                objData.subjectDetailArr = []; // 复选框选择的值
                                objData.subjectDetailData = [];

                                objData.result = 'pass'; // 	结果
                                objData.resultData = '';// 结果数据

                                objData.enclosure = ''; // 	 附件
                                objData.detail = ''; // 整体评估描述
                                agentAddDueTableData.push(objData);
                                table.reload('addDueTable', {data: agentAddDueTableData});
                            }
                        });

                        // 工具条点击事件
                        table.on('tool(addDueTable)', function (obj) {
                            let data = obj.data;
                            if (obj.event === 'del') { // 删除
                                agentAddDueTableData.splice(obj.tr.index(), 1);
                                table.reload('addDueTable', {data: agentAddDueTableData});
                            }
                        });

                        form.on("select", function (data) {
                            if ($(data.elem).attr('name') == 'subjectId') {
                                if (data.value && data.value != '') {
                                    agentAddDueTableData[$(data.elem).parents('tr').index()].subjectId = data.value;
                                    //agentAddDueTableData[$(data.elem).parents('tr').index()].subjectType = $(data.elem).find("option:selected").attr("type");
                                    agentAddDueTableData[$(data.elem).parents('tr').index()].subjectDetailData = $(data.elem).find("option:selected").attr("data").split(',');
                                } else {
                                    agentAddDueTableData[$(data.elem).parents('tr').index()].subjectId = '';
                                    //agentAddDueTableData[$(data.elem).parents('tr').index()].subjectType = '';
                                    agentAddDueTableData[$(data.elem).parents('tr').index()].subjectDetailData = [];
                                }
                                agentAddDueTableData[$(data.elem).parents('tr').index()].subjectDetail = '';
                                table.reload('addDueTable', {data: agentAddDueTableData});
                            } else if ($(data.elem).attr('name') == 'result') {
                                agentAddDueTableData[$(data.elem).parents('tr').index()].result = data.value;
                            }
                        });


                        // 尽调评述 操作（输入文本框）
                        $("body").delegate("[lay-id='addDueTable'] .subjectDetailBox input.subjectType", "change", function () {
                            if (agentAddDueTableData[$(this).parents('tr').index()]) {
                                agentAddDueTableData[$(this).parents('tr').index()].subjectDetail = $(this).val().trim();

                            }
                        });

                        $("body").delegate("[lay-id='addDueTable'] input[name='detail']", "change", function () {
                            if (agentAddDueTableData[$(this).parents('tr').index()]) {
                                agentAddDueTableData[$(this).parents('tr').index()].detail = $(this).val().trim();
                            }
                        });

                        form.on('submit(addDueFormSubmit)', function (d) {
                            if (agentAddDueTableData.length == 0) {
                                layer.msg('请添加记录', {icon: 5});
                                return false;
                            }
                            admin.req(data ? 'enterprise/sell/admin/customerDue/update' : 'enterprise/sell/admin/customerDue/addList', data ? JSON.stringify(agentAddDueTableData[0]) : JSON.stringify(agentAddDueTableData), res => {
                                if (res.code === 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('dueTable');
                                    layer.close(index);
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, data ? 'PUT' : 'POST', true, 'application/json; charset=utf-8');
                            return false;
                        })
                    }

                })
            }

            //尽调工具条点击事件
            table.on('tool(dueTable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'dueEdit') { //修改
                    dueFlag = true;
                    showDueEditModel(null, data);
                } else if (obj.event === 'dueDel') { // 删除
                    doDueDelete(obj);
                } else if (obj.event === 'dueCheck') { // 审核
                    doDueCheck(obj);
                } else if (obj.event === 'dueDetail') { // 详情
                    dueFlag = false;
                    showDueEditModel(null, data);
                }
            });

            // 尽调删除
            function doDueDelete(obj) {
                layer.confirm('确定要删除吗？', {
                    offset: '65px',
                    skin: 'layui-layer-admin'
                }, function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('enterprise/sell/admin/customerDue/' + obj.data.id, {}, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            obj.del();
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'DELETE');
                });
            }

            // 尽调审核
            function doDueCheck(obj) {
                layer.confirm('确定要审核吗？', {
                    offset: '65px',
                    btn: ['通过', '不通过'],
                    skin: 'layui-layer-admin'
                }, function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('enterprise/sell/admin/customerDue/check', JSON.stringify({
                        id: obj.data.id,
                        status: 'pass'
                    }), res => {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            table.reload('dueTable');
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'put', true, 'application/json; charset=utf-8');
                }, function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('enterprise/sell/admin/customerDue/check', JSON.stringify({
                        id: obj.data.id,
                        status: 'noPass'
                    }), res => {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            table.reload('dueTable');
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'put', true, 'application/json; charset=utf-8');
                });
            }

            //自定义验证（单选、复选框）
            form.verify({
                otherReq: function (value, item) {
                    var verifyName = $(item).attr('name')
                        , verifyType = $(item).attr('type')
                        , formElem = $(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
                        , verifyElem = formElem.find("input[name='" + verifyName + "']")//获取需要校验的元素
                        , isTrue = verifyElem.is(':checked')//是否命中校验
                        , focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
                    if (!isTrue || !value) {
                        //定位焦点
                        focusElem.css(verifyType == 'radio' ? {"color": "#FF5722"} : {"border-color": "#FF5722"});
                        //对非输入框设置焦点
                        focusElem.first().attr("tabIndex", "1").css("outline", "0").blur(function () {
                            focusElem.css(verifyType == 'radio' ? {"color": ""} : {"border-color": ""});
                        }).focus();
                        return '必填项不能为空';
                    }
                }
            });

        }


        // 获取客户数据
        function getCompany(data) {
            admin.req('enterprise/sell/admin/customersInfo/getCustomerByType', {customerTypeName: data.value}, function (res) {
                if (res.code == 200) {
                    loadSelectHtml(res.data, "请选择跟进客户", "followCustomer", "customerName");

                    if (data && data.followCustomer) {
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }
                } else {
                    loadSelectHtml(res.data, "请选择跟进客户", "followCustomer", "customerName");
                    layer.msg(res.msg, {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        // 获取客户联系人
        function getContactInfo(data) {
            admin.req('enterprise/sell/admin/contactInfo/list', {selCustomerId: data.value}, function (res) {
                if (res.code == 200) {
                    loadSelectHtml(res.data, "请选择跟进对象", "followTarget", "name")

                    if (data && data.followTarget) {
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }
                } else {
                    layer.msg('获取联系人失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        // 获取跟进类型
        function getFollowType(data) {
            admin.req('enterprise/sell/admin/customerFollowType/list', {limit: 9999}, function (res) {
                if (res.code == 200) {
                    var html = '<option value="">请选择跟进类型</option>';
                    for (var k = 0; k < res.data.length; k++) {
                        html += '<option value="' + res.data[k].code + '">' + res.data[k].name + '</option>';
                    }
                    $("form select[name='followType']").html(html);
                    form.render('select');
                    if (data && data.followType) {
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }

                } else {
                    layer.msg('获取跟进类型失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        // 获取跟进方式
        function getFollowWay(data) {
            admin.req('enterprise/sell/admin/customerFollowWay/list', {limit: 9999}, function (res) {
                if (res.code == 200) {
                    var html = '<option value="">请选择跟进方式</option>';
                    for (var k = 0; k < res.data.length; k++) {
                        html += '<option value="' + res.data[k].code + '">' + res.data[k].name + '</option>';
                    }
                    $("form select[name='followWay']").html(html);
                    form.render('select');
                    if (data && data.followWay) {
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }

                } else {
                    layer.msg('获取跟进方式失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        //获取跟进结果类型
        function getFollowResultType(data) {
            admin.req('enterprise/sell/admin/customerFollowResultType/list', {limit: 9999}, function (res) {
                if (res.code == 200) {
                    var html = '<option value="">请选择跟进结果类型</option>';
                    for (var k = 0; k < res.data.length; k++) {
                        html += '<option value="' + res.data[k].code + '">' + res.data[k].name + '</option>';
                    }
                    $("form select[name='followResult']").html(html);
                    form.render('select');
                    if (data && data.followResult) {
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }

                } else {
                    layer.msg('获取跟进结果类型失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        //获取审批人/业务员
        function getUsers(data) {
            admin.req('user/admin/user/list', {limit: 9999}, function (res) {
                if (res.code == 200) {
                    var html = '<option value="">请选择审批人/业务员</option>';
                    for (var k = 0; k < res.data.length; k++) {
                        html += '<option value="' + res.data[k].id + '">' + res.data[k].nickname+'/'+ res.data[k].username+ '</option>';
                    }
                    console.log('res.data',res.data)
                    $("form select[name='approver']").html(html);
                    $("form select[name='salesmanId']").html(html);
                    form.render('select');
                    if (data) {
                        $("#salesmanId").val(data.salesmanId);
                        form.render('select');
                        form.val('customerFollowRecordForm', data);
                        form.val('customerFollowRecordDetailForm', data);
                    }

                } else {
                    layer.msg('获取审批人失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        //获取代理商
        function getAgentInfo() {
            admin.req('enterprise/sell/admin/agent/list', {limit: 9999, status: '2,3'}, function (res) {
                if (res.code == 200) {
                    var html = '<option value="">请选择所属代理商</option>';
                    for (var k = 0; k < res.data.length; k++) {
                        html += '<option value="' + res.data[k].id + '">' + res.data[k].name + '</option>';
                    }
                    $("form select[name='selAgtId']").html(html);
                    form.render('select');
                    /* if(data && data.selAgtId){
                         form.val('customerFollowRecordForm', data);
                     }*/

                } else {
                    layer.msg('获取代理商失败', {icon: 2, time: 1000});
                }
            }, 'GET');
        }

        /**
         * 加载地址HTML
         * @param data 下拉菜单数据
         * @param tips select 默认提示
         * @param htmltarget html要插入的位置
         * @param name  下拉框需要显示值的属性
         */
        function loadSelectHtml(data, tips, htmltarget, name) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                html += `<option value='${data[i].id}'>${data[i][name]}</option>`;
            }
            $("[name='" + htmltarget + "']").html(html);
            form.render('select');
        }

        // 上传图片
        function uploadImg(_elem, pathId, inputId) {
            upload.render({
                elem: '#' + _elem
                , url: config.upload_url + 'uploadFile'
                , data: {}
                , accept: 'file'
                , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                , headers: {Authorization: 'Bearer ' + config.getToken()}
                , done: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg || "上传成功", {icon: 1});
                        let imagUrl = res.data.url;
                        $('#' + pathId).html('<img src="' + imagUrl + '" style="height: 35px;"/>');
                        $('#' + inputId).val(imagUrl);
                    } else if (res.code == 502) {
                        return location.replace('admin/login.html');
                    } else {
                        layer.msg(res.msg || "上传失败", {icon: 2});
                    }
                }
            });
        }

    });
</script>
<style>
    .layui-layer  .layui-table-view .layui-table-tool {
        position: relative;
        top: 0;
    }
</style>